InwardDependency cop: resolve LedgerPath against the config file, not the working directory #1143

Closed
opened 2026-10-18 23:30:44 +00:00 by jared · 4 comments
Owner

Problem

plugins/os-sdlc/.rubocop-sweep.yml sets LedgerPath: ../../docs/crc/os-sdlc/ledger.tsv.
ledger_path in lib/os_sdlc/cops/inward_dependency.rb does File.expand_path(configured).
That call resolves against Dir.pwd.
From the repo root, plugins/os-sdlc/bin/lint-sweep points outside the tree.
Ledger#role_by_const raises Sdlc/Structural/InwardDependency LedgerPath does not exist: ....
Rubocop prints An error occurred while Sdlc/Structural/InwardDependency cop was inspecting ... for every lib file (5628 lines on c7539a22) and exits 0.
The gate passes with no inward check.
From plugins/os-sdlc/ it works (176 offenses, 125 unique file/constant/outer/inner edges on c7539a22).

Part 1 shipped in 5e3cd884 (implementation 70): Lint::WorklistRubocopConfig writes each relative *Path parameter of an inherited config as an absolute path, so bin/lint-sweep reports the same InwardDependency offense set from the repo root and from plugins/os-sdlc/; a missing ledger gives one error line and exit 3 (tests/lint/lint_sweep_test.rb). The cop itself still resolves a relative LedgerPath against Dir.pwd, so a direct rubocop run with --config plugins/os-sdlc/.rubocop-sweep.yml from the repo root still crashes on every file.

Reproduce

cd plugins/os-sdlc && BUNDLE_GEMFILE=$PWD/Gemfile bundle exec rubocop --config .rubocop-sweep.yml --only Sdlc/Structural/InwardDependency lib/os_sdlc/agent.rb
cd ../.. && BUNDLE_GEMFILE=plugins/os-sdlc/Gemfile bundle exec rubocop --config plugins/os-sdlc/.rubocop-sweep.yml --only Sdlc/Structural/InwardDependency plugins/os-sdlc/lib/os_sdlc/agent.rb

The first run reports offenses. The second prints "An error occurred while Sdlc/Structural/InwardDependency".

Approach

The crc-tickets acceptance text needs no change: BodyContext#acceptance_lines (lib/os_sdlc/crc/tickets/body_context.rb:26-31) takes the inward lint command from the caller and hard-codes no directory.

Required work:

  1. InwardDependency#ledger_path expands a relative LedgerPath against the directory of config.loaded_path, never against Dir.pwd. An absolute LedgerPath (as part 1 writes) is unchanged.

Acceptance criteria

  1. Given a config file in a directory that names LedgerPath relative to that directory, when the cop inspects a file with the working directory elsewhere, then the cop reads that ledger and reports its offenses.

Owner sketch

  • RuboCop::Cop::Sdlc::Structural::InwardDependency#ledger_path (lib/os_sdlc/cops/inward_dependency.rb:65-70): expands a relative LedgerPath against File.dirname(config.loaded_path).
  • Tests: tests/cops/inward_dependency_test.rb (a RuboCop::Config with a loaded_path and a relative LedgerPath).

Origin

  • Session: ca7a7686-22a8-4463-86d5-c542e7d9f215
  • Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os/ca7a7686-22a8-4463-86d5-c542e7d9f215.jsonl
  • Where: plugins/os-sdlc/lib/os_sdlc/cops/inward_dependency.rb:65-70; plugins/os-sdlc/.rubocop-sweep.yml:8-10
  • Root candidate: none found; searched InwardDependency, LedgerPath, lint-sweep, cop crash, #1102
  • Run: CRC refactor run 2, docs/crc/os-sdlc (HANDOFF.md, deviations.md)
    VERDICT: CREATE
## Problem plugins/os-sdlc/.rubocop-sweep.yml sets `LedgerPath: ../../docs/crc/os-sdlc/ledger.tsv`. `ledger_path` in lib/os_sdlc/cops/inward_dependency.rb does `File.expand_path(configured)`. That call resolves against Dir.pwd. From the repo root, `plugins/os-sdlc/bin/lint-sweep` points outside the tree. `Ledger#role_by_const` raises `Sdlc/Structural/InwardDependency LedgerPath does not exist: ...`. Rubocop prints `An error occurred while Sdlc/Structural/InwardDependency cop was inspecting ...` for every lib file (5628 lines on c7539a22) and exits 0. The gate passes with no inward check. From plugins/os-sdlc/ it works (176 offenses, 125 unique file/constant/outer/inner edges on c7539a22). Part 1 shipped in 5e3cd884 (implementation 70): `Lint::WorklistRubocopConfig` writes each relative `*Path` parameter of an inherited config as an absolute path, so `bin/lint-sweep` reports the same InwardDependency offense set from the repo root and from plugins/os-sdlc/; a missing ledger gives one error line and exit 3 (tests/lint/lint_sweep_test.rb). The cop itself still resolves a relative LedgerPath against Dir.pwd, so a direct rubocop run with `--config plugins/os-sdlc/.rubocop-sweep.yml` from the repo root still crashes on every file. ## Reproduce ``` cd plugins/os-sdlc && BUNDLE_GEMFILE=$PWD/Gemfile bundle exec rubocop --config .rubocop-sweep.yml --only Sdlc/Structural/InwardDependency lib/os_sdlc/agent.rb cd ../.. && BUNDLE_GEMFILE=plugins/os-sdlc/Gemfile bundle exec rubocop --config plugins/os-sdlc/.rubocop-sweep.yml --only Sdlc/Structural/InwardDependency plugins/os-sdlc/lib/os_sdlc/agent.rb ``` The first run reports offenses. The second prints "An error occurred while Sdlc/Structural/InwardDependency". ## Approach The crc-tickets acceptance text needs no change: `BodyContext#acceptance_lines` (lib/os_sdlc/crc/tickets/body_context.rb:26-31) takes the inward lint command from the caller and hard-codes no directory. Required work: 1. `InwardDependency#ledger_path` expands a relative LedgerPath against the directory of `config.loaded_path`, never against Dir.pwd. An absolute LedgerPath (as part 1 writes) is unchanged. ## Acceptance criteria 1. Given a config file in a directory that names `LedgerPath` relative to that directory, when the cop inspects a file with the working directory elsewhere, then the cop reads that ledger and reports its offenses. ## Owner sketch - `RuboCop::Cop::Sdlc::Structural::InwardDependency#ledger_path` (lib/os_sdlc/cops/inward_dependency.rb:65-70): expands a relative LedgerPath against `File.dirname(config.loaded_path)`. - Tests: tests/cops/inward_dependency_test.rb (a `RuboCop::Config` with a `loaded_path` and a relative LedgerPath). ## Origin - Session: ca7a7686-22a8-4463-86d5-c542e7d9f215 - Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os/ca7a7686-22a8-4463-86d5-c542e7d9f215.jsonl - Where: plugins/os-sdlc/lib/os_sdlc/cops/inward_dependency.rb:65-70; plugins/os-sdlc/.rubocop-sweep.yml:8-10 - Root candidate: none found; searched InwardDependency, LedgerPath, lint-sweep, cop crash, #1102 - Run: CRC refactor run 2, docs/crc/os-sdlc (HANDOFF.md, deviations.md) VERDICT: CREATE
Author
Owner

Work started on branch ticket-1143 (worktree .claude/worktrees/ticket-1143), through /os-sdlc:implement. Same branch also carries: Exclude retirement for InwardDependency, the per-kind cop split, and #1072 ambiguous keep rows.

Work started on branch ticket-1143 (worktree .claude/worktrees/ticket-1143), through /os-sdlc:implement. Same branch also carries: Exclude retirement for InwardDependency, the per-kind cop split, and #1072 ambiguous keep rows.
Author
Owner

Implementation 70 failed at contract-auditor (verdict:error, dispatch 658): R2 and R3 were green (suite pass, behavior-verifier pass) and are committed as 5e3cd884; R1 (cop-side resolution against config.loaded_path) was missing and needed a new test, which contract-auditor cannot route back to test-writer. Cause: R1 had no acceptance criterion of its own. Body now scopes the remaining work to R1 with its own criterion; fresh implementation follows on branch ticket-1143.

Implementation 70 failed at contract-auditor (verdict:error, dispatch 658): R2 and R3 were green (suite pass, behavior-verifier pass) and are committed as 5e3cd884; R1 (cop-side resolution against config.loaded_path) was missing and needed a new test, which contract-auditor cannot route back to test-writer. Cause: R1 had no acceptance criterion of its own. Body now scopes the remaining work to R1 with its own criterion; fresh implementation follows on branch ticket-1143.
Author
Owner

Follow-up dropped by ticket-skeptic: contract-auditor has no route for a test-needing WORK-MISSING item (implementation 70 ended verdict:error). The root is upstream: change-auditor accepted R1 with no criterion of its own; recovered by implementation 73.

Follow-up dropped by ticket-skeptic: contract-auditor has no route for a test-needing WORK-MISSING item (implementation 70 ended verdict:error). The root is upstream: change-auditor accepted R1 with no criterion of its own; recovered by implementation 73.
Author
Owner

Resolution

Done: Relative LedgerPath resolves against the directory of the config file that sets it: the cop expands it against config.loaded_path (ccd16090), and lint-sweep's generated config carries inherited *Path parameters as absolute paths, refusing a missing one with one line and exit 3 (5e3cd884). crc-tickets acceptance text needed no change.

Evidence: Merged to main 0cd8943e. Suite 2108 runs, 0 failures. bin/lint-sweep from plugins/os-sdlc/ and from the repo root: 176 InwardDependency offenses each (125 unique edges), identical sets, 0 InwardDependency crash lines (was 5628 from the root). Implementations 70 (failed at contract-auditor, green part kept) and 73 (complete).

Follow-ups: contract-auditor route for test-needing WORK-MISSING: dropped by ticket-skeptic (root is upstream, see comment). Origin-check defect seen while filing: occurrence posted on #965. Cop split continues as #1153.

## Resolution **Done:** Relative LedgerPath resolves against the directory of the config file that sets it: the cop expands it against config.loaded_path (ccd16090), and lint-sweep's generated config carries inherited *Path parameters as absolute paths, refusing a missing one with one line and exit 3 (5e3cd884). crc-tickets acceptance text needed no change. **Evidence:** Merged to main 0cd8943e. Suite 2108 runs, 0 failures. bin/lint-sweep from plugins/os-sdlc/ and from the repo root: 176 InwardDependency offenses each (125 unique edges), identical sets, 0 InwardDependency crash lines (was 5628 from the root). Implementations 70 (failed at contract-auditor, green part kept) and 73 (complete). **Follow-ups:** contract-auditor route for test-needing WORK-MISSING: dropped by ticket-skeptic (root is upstream, see comment). Origin-check defect seen while filing: occurrence posted on #965. Cop split continues as #1153.
jared closed this issue 2026-10-19 12:20:59 +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#1143
No description provided.