Inject target and agent id; delete ENV reads in library code (absorbs #577) #633

Closed
opened 2026-09-23 12:04:20 +00:00 by jared · 2 comments
Owner

Context

User requested during the shell-call/ENV audit in session 16bf37b3-8cff-4121-896c-4a5fc61f2e9e. The user believed OS_SDLC_TARGET was already removed. #577 (open, filed 2026-09-14) already targets the OS_SDLC_TARGET fallback specifically; this ticket absorbs #577's remaining scope, adds the CC_OS_AGENT_ID and Dir.pwd fallback sites the audit found, and states the decided replacement design: target comes from the persisted implementation record (implementation.target), not ENV; the agent id is passed as a parameter by the calling hook or skill, not read from ENV.

Observed

plugins/os-sdlc/lib/os_sdlc/cli/target_flag.rb:7        return ENV.fetch("OS_SDLC_TARGET", nil) unless index
plugins/os-sdlc/lib/os_sdlc/lint/worklist_target.rb:12   def self.load(dir = Dir.pwd, target: ENV.fetch("OS_SDLC_TARGET", nil))
plugins/os-sdlc/lib/os_sdlc/lint/worklist_report.rb:51   index ? argv.slice!(index, 2)[1] : ENV.fetch("OS_SDLC_TARGET", nil)
plugins/os-sdlc/tests/test_helper.rb:170                 ENV.delete("OS_SDLC_TARGET")
plugins/os-backlog/lib/backlog/checkout.rb:42            ENV["CC_OS_AGENT_ID"] || @assignee
plugins/os-sdlc/lib/os_sdlc/hook/pipe.rb:49               Dir.pwd
plugins/os-sdlc/lib/os_sdlc/hook/lint_changed/trigger.rb:18   @event["cwd"] || Dir.pwd

#577 (open) already lists a near-identical OS_SDLC_TARGET fallback set from a 2026-09-14 grep, at slightly different line numbers (target_flag.rb:7, lint_worklist_target.rb:17, lint_worklist_report.rb:56,59, plus project_targets.rb error text, two SKILL.md mentions, and test_helper.rb/gate_commands_test.rb env setup). The files have since moved under lib/os_sdlc/cli/ and lib/os_sdlc/lint/ and the line numbers shifted, but the underlying fallback is still present. #577 requests an ADR superseding the ADR-0088 env-fallback clause; this ticket keeps that requirement and adds the CC_OS_AGENT_ID and Dir.pwd cwd-fallback sites this audit found, which #577 does not cover.

Reproduce

grep -rn "OS_SDLC_TARGET\|CC_OS_AGENT_ID" plugins/os-sdlc plugins/os-backlog --include='*.rb'

Expected

One prose sentence: no library code reads OS_SDLC_TARGET or CC_OS_AGENT_ID from ENV; target comes from implementation.target on the persisted implementation record, and the agent id is passed as an explicit parameter from the caller (hook or skill) into os-backlog.

Origin

  • Trigger: shell-call/ENV audit, session 16bf37b3-8cff-4121-896c-4a5fc61f2e9e (2026-09-23), user-requested; absorbs #577 (filed 2026-09-14, still open).
  • Improvised this session: none
  • Chain: ENV coupling in library code <- OS_SDLC_TARGET/CC_OS_AGENT_ID fallbacks read process-global env instead of receiving injected values <- DESIGN, ADR-0088 env-fallback clause (superseded by this ticket's ADR).
  • Root candidate: this ticket
  • Where: plugins/os-sdlc/lib/os_sdlc/cli/target_flag.rb, lint/worklist_target.rb, lint/worklist_report.rb; plugins/os-backlog/lib/backlog/checkout.rb; plugins/os-sdlc/lib/os_sdlc/hook/pipe.rb, hook/lint_changed/trigger.rb
  • Session: e67968b8-85aa-4299-a323-a8c2212f7140 (#577's original grep, 2026-09-14); 16bf37b3-8cff-4121-896c-4a5fc61f2e9e (this audit)
  • Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os/16bf37b3-8cff-4121-896c-4a5fc61f2e9e.jsonl (this session); #577 cites /home/jared/.claude/projects/-home-jared-dev-cc-os/e67968b8-85aa-4299-a323-a8c2212f7140.jsonl for its own origin

Acceptance criteria

  • OS_SDLC_TARGET is never read from ENV anywhere in plugins/os-sdlc; target_flag.rb, worklist_target.rb, worklist_report.rb read only --target NAME or implementation.target.
  • test_helper.rb's ENV.delete("OS_SDLC_TARGET") is removed (no ENV to delete).
  • CC_OS_AGENT_ID is never read from ENV in plugins/os-backlog/lib/backlog/checkout.rb; the agent id arrives as a parameter.
  • Dir.pwd fallbacks in hook/pipe.rb and hook/lint_changed/trigger.rb are replaced by an injected cwd (coordinate with #631's invocation-seam ticket rather than duplicating it).
  • project_targets.rb error text (if still present) names only --target NAME, no env var.
  • An ADR is created via /os-adr:create that supersedes the ADR-0088 env-fallback clause. The ticket is not done without it.

Relationship to #577

#577 is open and already targets the OS_SDLC_TARGET fallback specifically, at file:line locations that have since shifted. This ticket absorbs #577's remaining scope and extends it to CC_OS_AGENT_ID and the Dir.pwd cwd fallbacks the audit additionally found. Do not close #577 from here; this report only states the relationship for a human to act on.

## Context User requested during the shell-call/ENV audit in session 16bf37b3-8cff-4121-896c-4a5fc61f2e9e. The user believed OS_SDLC_TARGET was already removed. #577 (open, filed 2026-09-14) already targets the OS_SDLC_TARGET fallback specifically; this ticket absorbs #577's remaining scope, adds the CC_OS_AGENT_ID and Dir.pwd fallback sites the audit found, and states the decided replacement design: target comes from the persisted implementation record (`implementation.target`), not ENV; the agent id is passed as a parameter by the calling hook or skill, not read from ENV. ## Observed ``` plugins/os-sdlc/lib/os_sdlc/cli/target_flag.rb:7 return ENV.fetch("OS_SDLC_TARGET", nil) unless index plugins/os-sdlc/lib/os_sdlc/lint/worklist_target.rb:12 def self.load(dir = Dir.pwd, target: ENV.fetch("OS_SDLC_TARGET", nil)) plugins/os-sdlc/lib/os_sdlc/lint/worklist_report.rb:51 index ? argv.slice!(index, 2)[1] : ENV.fetch("OS_SDLC_TARGET", nil) plugins/os-sdlc/tests/test_helper.rb:170 ENV.delete("OS_SDLC_TARGET") plugins/os-backlog/lib/backlog/checkout.rb:42 ENV["CC_OS_AGENT_ID"] || @assignee plugins/os-sdlc/lib/os_sdlc/hook/pipe.rb:49 Dir.pwd plugins/os-sdlc/lib/os_sdlc/hook/lint_changed/trigger.rb:18 @event["cwd"] || Dir.pwd ``` #577 (open) already lists a near-identical OS_SDLC_TARGET fallback set from a 2026-09-14 grep, at slightly different line numbers (target_flag.rb:7, lint_worklist_target.rb:17, lint_worklist_report.rb:56,59, plus project_targets.rb error text, two SKILL.md mentions, and test_helper.rb/gate_commands_test.rb env setup). The files have since moved under lib/os_sdlc/cli/ and lib/os_sdlc/lint/ and the line numbers shifted, but the underlying fallback is still present. #577 requests an ADR superseding the ADR-0088 env-fallback clause; this ticket keeps that requirement and adds the CC_OS_AGENT_ID and Dir.pwd cwd-fallback sites this audit found, which #577 does not cover. ## Reproduce ``` grep -rn "OS_SDLC_TARGET\|CC_OS_AGENT_ID" plugins/os-sdlc plugins/os-backlog --include='*.rb' ``` ## Expected One prose sentence: no library code reads OS_SDLC_TARGET or CC_OS_AGENT_ID from ENV; target comes from `implementation.target` on the persisted implementation record, and the agent id is passed as an explicit parameter from the caller (hook or skill) into os-backlog. ## Origin - Trigger: shell-call/ENV audit, session 16bf37b3-8cff-4121-896c-4a5fc61f2e9e (2026-09-23), user-requested; absorbs #577 (filed 2026-09-14, still open). - Improvised this session: none - Chain: ENV coupling in library code <- OS_SDLC_TARGET/CC_OS_AGENT_ID fallbacks read process-global env instead of receiving injected values <- DESIGN, ADR-0088 env-fallback clause (superseded by this ticket's ADR). - Root candidate: this ticket - Where: plugins/os-sdlc/lib/os_sdlc/cli/target_flag.rb, lint/worklist_target.rb, lint/worklist_report.rb; plugins/os-backlog/lib/backlog/checkout.rb; plugins/os-sdlc/lib/os_sdlc/hook/pipe.rb, hook/lint_changed/trigger.rb - Session: e67968b8-85aa-4299-a323-a8c2212f7140 (#577's original grep, 2026-09-14); 16bf37b3-8cff-4121-896c-4a5fc61f2e9e (this audit) - Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os/16bf37b3-8cff-4121-896c-4a5fc61f2e9e.jsonl (this session); #577 cites /home/jared/.claude/projects/-home-jared-dev-cc-os/e67968b8-85aa-4299-a323-a8c2212f7140.jsonl for its own origin ## Acceptance criteria - [ ] OS_SDLC_TARGET is never read from ENV anywhere in plugins/os-sdlc; target_flag.rb, worklist_target.rb, worklist_report.rb read only --target NAME or implementation.target. - [ ] test_helper.rb's ENV.delete("OS_SDLC_TARGET") is removed (no ENV to delete). - [ ] CC_OS_AGENT_ID is never read from ENV in plugins/os-backlog/lib/backlog/checkout.rb; the agent id arrives as a parameter. - [ ] Dir.pwd fallbacks in hook/pipe.rb and hook/lint_changed/trigger.rb are replaced by an injected cwd (coordinate with #631's invocation-seam ticket rather than duplicating it). - [ ] project_targets.rb error text (if still present) names only --target NAME, no env var. - [ ] An ADR is created via /os-adr:create that supersedes the ADR-0088 env-fallback clause. The ticket is not done without it. ## Relationship to #577 #577 is open and already targets the OS_SDLC_TARGET fallback specifically, at file:line locations that have since shifted. This ticket absorbs #577's remaining scope and extends it to CC_OS_AGENT_ID and the Dir.pwd cwd fallbacks the audit additionally found. Do not close #577 from here; this report only states the relationship for a human to act on.
Author
Owner

Work started 2026-09-24 in worktree branch ticket-633. Blast radius checked: TargetFlag.extract! (1 caller), WorklistTarget.load (report + 5 test sites), Backlog::Checkout (cli.rb checkout; gains --agent-id), Hook::Pipe#cwd (3 live callers), LintChanged::Trigger#directory. Decision: missing event cwd raises; agent id arrives via --agent-id. New ADR supersedes ADR-0088 env clause and amends ADR-0210 selection wording. #577 is already closed.

Work started 2026-09-24 in worktree branch ticket-633. Blast radius checked: TargetFlag.extract! (1 caller), WorklistTarget.load (report + 5 test sites), Backlog::Checkout (cli.rb checkout; gains --agent-id), Hook::Pipe#cwd (3 live callers), LintChanged::Trigger#directory. Decision: missing event cwd raises; agent id arrives via --agent-id. New ADR supersedes ADR-0088 env clause and amends ADR-0210 selection wording. #577 is already closed.
Author
Owner

Resolution

Done: Removed every ENV fallback in library code. Target comes only from --target NAME or implementation.target (target_flag.rb, worklist_target.rb, worklist_report.rb, project_targets.rb error text). Backlog checkout gains --agent-id; Checkout takes agent_id: and no longer reads CC_OS_AGENT_ID. Hook::Pipe and LintChanged::Trigger take cwd from the event and raise when absent. test_helper ENV.delete removed. fix-lints and setup-project SKILL.md name --target only. ADR-0213 supersedes the ADR-0088 env clause and amends ADR-0210 rule 2 and ADR-0207. History rows added to os-sdlc and os-backlog leaves.

Evidence: Merged to main 2026-09-24, commit 7714b9ce (branch worktree-ticket-633). os-sdlc suite 1412 runs 0 failures; os-backlog suite 244 runs 0 failures. rubocop: no new offenses. grep OS_SDLC_TARGET|CC_OS_AGENT_ID over plugins returns only tests that prove the vars are ignored. Blast radius checked via os-sdlc:blast-radius before work. #577 already closed.

Follow-ups: none: docs/os-sdlc-rebuild history files and older ADRs still mention OS_SDLC_TARGET as historical record, left as-is by convention; worklist_report.rb accepts --target NAME but not --target=NAME, pre-existing and unchanged; os-backlog cli.rb carries 36 pre-existing Metrics offenses, untouched

## Resolution **Done:** Removed every ENV fallback in library code. Target comes only from --target NAME or implementation.target (target_flag.rb, worklist_target.rb, worklist_report.rb, project_targets.rb error text). Backlog checkout gains --agent-id; Checkout takes agent_id: and no longer reads CC_OS_AGENT_ID. Hook::Pipe and LintChanged::Trigger take cwd from the event and raise when absent. test_helper ENV.delete removed. fix-lints and setup-project SKILL.md name --target only. ADR-0213 supersedes the ADR-0088 env clause and amends ADR-0210 rule 2 and ADR-0207. History rows added to os-sdlc and os-backlog leaves. **Evidence:** Merged to main 2026-09-24, commit 7714b9ce (branch worktree-ticket-633). os-sdlc suite 1412 runs 0 failures; os-backlog suite 244 runs 0 failures. rubocop: no new offenses. grep OS_SDLC_TARGET|CC_OS_AGENT_ID over plugins returns only tests that prove the vars are ignored. Blast radius checked via os-sdlc:blast-radius before work. #577 already closed. **Follow-ups:** none: docs/os-sdlc-rebuild history files and older ADRs still mention OS_SDLC_TARGET as historical record, left as-is by convention; worklist_report.rb accepts --target NAME but not --target=NAME, pre-existing and unchanged; os-backlog cli.rb carries 36 pre-existing Metrics offenses, untouched
jared closed this issue 2026-09-24 19:26:31 +00:00
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#633
No description provided.