Apply ADR-0205 env discipline to os and os-backlog tests; shared git seed #634
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#634
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
Global ENV mutation in test helpers blocks parallel test runs for
plugins/osandplugins/os-backlog, and each worktree test forks its own git init sequence. The original ticket's five-file list is stale: batches #672/#677/#697 folded the worktree helpers into one shared file.Observed
plugins/os/tests/support/worktree_finish_test_case.rb:27with_path_prependedsaves, sets, and restoresENV['PATH']globally (5 callers).plugins/os/tests/support/worktree_finish_test_case.rb:35seed_reporuns fivesystem('git', ...)calls per test (callers includefinish_command_missing_worktree_test.rb:13,finish_command_resolves_by_branch_test.rb:14, and the otherseed_repo_and_start_worktreeusers).plugins/os-backlog/tests/support/cli_test_helpers.rb:19with_isolated_project_indexsetsENV["CC_OS_HOME"]globally (5 callers:cli_projects_command_test,cli_config_write_command_test,cli_unknown_command_test,cli_issue_create_scope_gate_test,cli_json_first_rendering_test).plugins/os-backlog/tests/support/labels_cli_helpers.rb:49run_cliinterpolatesPATHinto a backtick shell string (3 callers).plugins/os/tests/all.rbnorplugins/os-backlog/tests/test_helper.rbdeclaresparallelize_me!.plugins/os-sdlc/tests/test_helper.rb:167does, plus aSerializedChdirmonitor, becauseDir.chdirraces persisted there even after env discipline (ADR-0205 consequence).Backlog::ProjectIndex.default_path(env: ENV)(plugins/os-backlog/lib/backlog/project_index.rb:9) andBacklog::Wakeup::State(plugins/os-backlog/lib/backlog/wakeup/state.rb:9) already accept anenv:keyword, butBacklog::CLIdoes not thread env down to them — the CC_OS_HOME callers runBacklog::CLI.startin-process, so the fix needs lib plumbing, not just test-side changes.plugins/os/libnever readsENV['PATH']itself, but itssystem(...)calls take no env hash, so child spawns (rubocop server stop, os-sdlc-runner sweep) inherit whatever the test process set globally.Reproduce
Approach
Backlog::CLI.starttakes anenv:keyword (Invocation-shaped, following the ADR-0207 pattern) and threads it toProjectIndex/Wakeup::State; tests then callBacklog::CLI.start(args, env: {"CC_OS_HOME" => home})instead of mutatingENV.with_path_prependedis replaced by passing an env hash to eachsystem/Open3call insideWorktree::CLI/FinishCommand, which need anenv:parameter added at the same seam.labels_cli_helpers.rbspawns viasystem(env_hash, "ruby", BIN, *args, chdir: dir)(orOpen3) instead of a backtick with a string-interpolatedPATH=.Required work:
Backlog::CLI.startacceptsenv:and passes it toProjectIndex.default_path/Wakeup::State— check:grep -n "env:" plugins/os-backlog/lib/backlog/cli.rbshows the new parameter.cli_test_helpers.rbpassesenv:instead of writingENV— check:grep -rn "ENV\[" plugins/os-backlog/testsreturns nothing that assigns.labels_cli_helpers.rbspawns via an env hash, not a shell-interpolated string — check:grep -n "PATH=" plugins/os-backlog/tests/support/labels_cli_helpers.rbreturns nothing.Worktree::FinishCommand/Worktree::CLIaccept anenv:hash threaded to theirsystem/Open3calls;with_path_prependeddeleted — check:grep -rn "ENV\['PATH'\] =" plugins/os/testsreturns nothing.plugins/os/tests/support/repo_seeder.rb, mirroringplugins/os-sdlc/tests/support/repo_seeder.rb: seed a git repo once per suite, thenFileUtils.cp_ra copy per test.parallelize_me!to bothplugins/os/tests/all.rbandplugins/os-backlog/tests/test_helper.rb, with cwd passed through the CLI or aSerializedChdirmonitor copied from os-sdlc ifDir.chdirraces persist — check:ruby plugins/os/tests/all.rbandruby -Iplugins/os-backlog -Iplugins/os-backlog/tests plugins/os-backlog/tests/test_helper.rbboth pass green on 3 consecutive runs./os-adr:create amends 0205, extending ADR-0205's affected-components list toplugins/osandplugins/os-backlog.Rejected: a tests-only change. The in-process
CC_OS_HOMEreads insideProjectIndex/Wakeup::Statecannot be fixed from the test side alone; the lib must acceptenv:.Non-goals:
plugins/os-sdlc(already done in #624). No new ADR beyond the amendment in item 7 — ADR-0205's pattern itself does not change, only its scope.Condition that would make this plan wrong: if some other in-process consumer of
Backlog::CLI.startoutside tests relies onENVbeing read directly rather than an injectedenv:hash, threadingenv:through could silently change its behavior; check allBacklog::CLI.startcall sites before wiring the parameter.VERDICT: CREATE
Acceptance criteria
Backlog::CLI.startis called with anenv:hash, when it resolves the project index or wakeup state, then it uses the passed hash, not globalENV.CC_OS_HOME, then no test assigns to globalENV["CC_OS_HOME"].labels_cli_helpers.rbspawns the CLI binary, whenPATHneeds a prepended fake bin directory, then it is passed as an env hash tosystem/Open3, never interpolated into a shell string.git init/config/add/commitsequence.plugins/os/tests/all.rbandplugins/os-backlog/tests/test_helper.rbrun withparallelize_me!enabled, then each suite passes green on 3 consecutive runs.plugins/osandplugins/os-backlogexists.Owner sketch
Non-goals
plugins/os-sdlc(already covered by #624).Origin
Resolution
Done: Split into per-plugin children; the ADR-0205 amendment extending affected-components to os and os-backlog is owed when both children ship
Evidence: #707, #708
Follow-ups: #707 (VERDICT: CREATE), #708 (VERDICT: CREATE); ADR-0205 amendment via /os-adr:create after both children ship, owner orchestrator session 082c3e8b, VERDICT: CREATE