Move os-me hook helper classes into lib/os_me so they autoload #1396
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#1396
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
Four os-me helper classes live in
plugins/os-me/hooks/. Hook scripts andlib/os_me.rbload them withrequire_relative.hooks/is outside the Zeitwerk tree. Each consumer names the file by hand. The library entry file reaches intohooks/. Under the Sdlc/RequireInsideCode lesson, arequire_relativeof project code belongs only to the loader in an entry point.Evidence (all four classes are
OsMe::constants, so Zeitwerk could autoload them fromlib/os_me/):plugins/os-me/lib/os_me.rb:12require_relative '../hooks/extract_launcher'loadsOsMe::ExtractLauncherplugins/os-me/hooks/extract_moments.rb:4require_relative 'extract_launcher'loadsOsMe::ExtractLauncherplugins/os-me/hooks/log_invocation.rb:5require_relative 'invocation_log'loadsOsMe::InvocationLogplugins/os-me/hooks/prediction_recorder.rb:5require_relative 'invocation_log'loadsOsMe::InvocationLogplugins/os-me/hooks/record_prediction.rb:6require_relative 'cli_appender'loadsOsMe::CliAppenderplugins/os-me/hooks/record_prediction.rb:7require_relative 'prediction_recorder'loadsOsMe::PredictionRecorderplugins/os-me/test/prediction_recorder_payload_provenance_test.rb:6-8andplugins/os-me/test/prediction_recorder_provenance_test.rb:6-8.The loader is
loader.push_dir(File.join(__dir__, 'os_me'), namespace: OsMe)inplugins/os-me/lib/os_me.rb. A file atlib/os_me/cli_appender.rbwould autoload asOsMe::CliAppender.Reproduce
n/a: design ticket; the
require_relativelines above show the shape.Approach
Move each helper class file into
lib/os_me/at the path its constant maps to. Each hook script keeps onerequire_relative '../lib/os_me'in its top run. Delete the otherrequire_relativecalls, including the one inlib/os_me.rband the test requires.Required work:
plugins/os-me/hooks/cli_appender.rbtoplugins/os-me/lib/os_me/cli_appender.rb— check: absentrequire_relative 'cli_appender'inplugins/os-me/hooks/*.rbplugins/os-me/hooks/extract_launcher.rbtoplugins/os-me/lib/os_me/extract_launcher.rb— check: absentrequire_relative 'extract_launcher'inplugins/os-me/hooks/*.rbplugins/os-me/hooks/invocation_log.rbtoplugins/os-me/lib/os_me/invocation_log.rb— check: absentrequire_relative 'invocation_log'inplugins/os-me/hooks/*.rbplugins/os-me/hooks/prediction_recorder.rbtoplugins/os-me/lib/os_me/prediction_recorder.rb— check: absentrequire_relative 'prediction_recorder'inplugins/os-me/hooks/*.rbextract_moments.rbandlog_invocation.rbstart withrequire_relative '../lib/os_me'only, and remove the sibling requires fromrecord_prediction.rbhooks/requires from the two provenance tests underplugins/os-me/test/hooks/require from the library entry file — check: absentrequire_relative '../hooks/inplugins/os-me/lib/**/*.rbAcceptance criteria
ruby test/all.rbinplugins/os-me), when it runs, then it passes.plugins/os-me/hooks/, when its requires are read, then it starts with only therequire_relative '../lib/os_me'loader.ruby plugins/os-me/hooks/extract_moments.rb, when it runs, then it exits 0 and launches the extraction as before (plugins/os-me/test/extract_launcher_test.rbruns it).Owner sketch
Related: #1367, #1393.
Origin
require_relativecalls inplugins/*/hooks/*.rbafter #1367hooks/, outside the Zeitwerk tree ← DESIGN (plugins/os-me/lib/os_me.rbpush_dirlib/os_meonly)