Key the RuboCop cache on the CRC ledger that the layer cops read #1173

Open
opened 2026-10-19 20:51:16 +00:00 by jared · 2 comments
Owner

Problem

The ledger-reading cops (Sdlc/Structural/UnlayeredConstant, Sdlc/Structural/InwardDependency) read docs/crc/os-sdlc/ledger.tsv through the LedgerPath setting. The RuboCop result cache keys on the inspected file and the config, not on the ledger file. After a ledger edit, lint-sweep replays a cached offense that the new ledger no longer supports. The inward delta then reports a false new offense, and a gate can fail on stale data.

Observed

Run 3 of the os-sdlc CRC pass, ticket #1169, created plugins/os-sdlc/lib/os_sdlc/fact_names.rb. The first lint-sweep reported UnlayeredConstant for OsSdlc::FactNames. I appended the FactNames row to the ledger. The next lint-sweep reported the same offense. With a fresh cache directory, the offense went away:

RUBOCOP_CACHE_ROOT=<fresh scratch dir> plugins/os-sdlc/bin/lint-sweep
{"before": 242, "after": 242, "new": [], "gone": [], "problems": []}

Reproduce

  1. Create a new constant file under plugins/os-sdlc/lib/os_sdlc/ with no ledger row, and run plugins/os-sdlc/bin/lint-sweep. It reports UnlayeredConstant.
  2. Append a ledger row for the file, and run plugins/os-sdlc/bin/lint-sweep again. It still reports the offense.
  3. Run it again with RUBOCOP_CACHE_ROOT set to an empty directory. The offense is gone.

Origin

  • Trigger: lint-sweep inward delta during the #1169 gate, os-sdlc CRC run 3
  • Improvised this session: ran lint-sweep with RUBOCOP_CACHE_ROOT set to a fresh scratch directory
  • Chain: stale UnlayeredConstant offense ← RuboCop result cache replays the earlier result ← the cache key does not include the ledger file that the cop reads (UPSTREAM-TOOL: RuboCop caches by file content and config; the cop reads an outside file in plugins/os-sdlc/lib/os_sdlc/cops/layer_ledger/ledger.rb)
  • Root candidate: none found; searched rubocop cache, ledger, lint-sweep, stale offense, UnlayeredConstant, LedgerPath
  • Where: plugins/os-sdlc/lib/os_sdlc/cops/layer_ledger/ledger.rb, plugins/os-sdlc/bin/lint-sweep
  • Session: 2e167079-f404-4139-9cfa-6c0c937ce9f0
  • Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os--claude-worktrees-crc-os-sdlc-run-3/2e167079-f404-4139-9cfa-6c0c937ce9f0.jsonl

VERDICT: CREATE

## Problem The ledger-reading cops (`Sdlc/Structural/UnlayeredConstant`, `Sdlc/Structural/InwardDependency`) read `docs/crc/os-sdlc/ledger.tsv` through the `LedgerPath` setting. The RuboCop result cache keys on the inspected file and the config, not on the ledger file. After a ledger edit, `lint-sweep` replays a cached offense that the new ledger no longer supports. The inward delta then reports a false new offense, and a gate can fail on stale data. ## Observed Run 3 of the os-sdlc CRC pass, ticket #1169, created `plugins/os-sdlc/lib/os_sdlc/fact_names.rb`. The first lint-sweep reported `UnlayeredConstant` for `OsSdlc::FactNames`. I appended the FactNames row to the ledger. The next lint-sweep reported the same offense. With a fresh cache directory, the offense went away: ``` RUBOCOP_CACHE_ROOT=<fresh scratch dir> plugins/os-sdlc/bin/lint-sweep ``` ``` {"before": 242, "after": 242, "new": [], "gone": [], "problems": []} ``` ## Reproduce 1. Create a new constant file under `plugins/os-sdlc/lib/os_sdlc/` with no ledger row, and run `plugins/os-sdlc/bin/lint-sweep`. It reports `UnlayeredConstant`. 2. Append a ledger row for the file, and run `plugins/os-sdlc/bin/lint-sweep` again. It still reports the offense. 3. Run it again with `RUBOCOP_CACHE_ROOT` set to an empty directory. The offense is gone. ## Origin - Trigger: lint-sweep inward delta during the #1169 gate, os-sdlc CRC run 3 - Improvised this session: ran lint-sweep with `RUBOCOP_CACHE_ROOT` set to a fresh scratch directory - Chain: stale `UnlayeredConstant` offense ← RuboCop result cache replays the earlier result ← the cache key does not include the ledger file that the cop reads (UPSTREAM-TOOL: RuboCop caches by file content and config; the cop reads an outside file in `plugins/os-sdlc/lib/os_sdlc/cops/layer_ledger/ledger.rb`) - Root candidate: none found; searched rubocop cache, ledger, lint-sweep, stale offense, UnlayeredConstant, LedgerPath - Where: plugins/os-sdlc/lib/os_sdlc/cops/layer_ledger/ledger.rb, plugins/os-sdlc/bin/lint-sweep - Session: 2e167079-f404-4139-9cfa-6c0c937ce9f0 - Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os--claude-worktrees-crc-os-sdlc-run-3/2e167079-f404-4139-9cfa-6c0c937ce9f0.jsonl VERDICT: CREATE
Author
Owner

Occurrence: Sdlc cops that read other files give stale results from the RuboCop cache
Seen: plugins/os-sdlc/lib/os_sdlc/cops/structural/adapter_built_outside_entry.rb (also Sdlc/Structural/OwnEntryPointSpawnedInTest)
Run: bc5ad309-36b7-4fe5-a67f-1d90187242eb
Adds: On 2026-11-09 in worktree ticket-1647-adapters, rubocop --only Sdlc/Structural/AdapterBuiltOutsideEntry lib/os_sdlc/evidence/resolution.rb reported a stale offense at line 28; with --cache false the file had none. Two more cops read other files. Fix: external_dependency_checksum (RuboCop 1.90.0). Acceptance: a cached clean result turns to an offense when the referenced constant file changes, and the reverse clears it. No --cache false in the gate.

Occurrence: Sdlc cops that read other files give stale results from the RuboCop cache Seen: plugins/os-sdlc/lib/os_sdlc/cops/structural/adapter_built_outside_entry.rb (also Sdlc/Structural/OwnEntryPointSpawnedInTest) Run: bc5ad309-36b7-4fe5-a67f-1d90187242eb Adds: On 2026-11-09 in worktree ticket-1647-adapters, rubocop --only Sdlc/Structural/AdapterBuiltOutsideEntry lib/os_sdlc/evidence/resolution.rb reported a stale offense at line 28; with --cache false the file had none. Two more cops read other files. Fix: external_dependency_checksum (RuboCop 1.90.0). Acceptance: a cached clean result turns to an offense when the referenced constant file changes, and the reverse clears it. No --cache false in the gate.
Author
Owner

Occurrence: four Sdlc/Structural/DomainEffectInEdge offenses in plugins/os-sdlc/test/system_model_catalog_test.rb (lines 33, 45, 49, 61) show only with the cache off
Seen: bundle exec rubocop --cache false test/system_model_catalog_test.rb, from plugins/os-sdlc, on main e16fd58bd and on 380176169 (same 4 offenses at both)
Run: Session 720a7477-bb8e-4373-8d74-6bbdb56f0200 (#1665 close-out)
Adds: the file last changed in the tests/ to test/ rename (4ff1a393d), so the offenses are older than today's work, and the cached gate did not report them. Each flagged line is assert_empty or assert_equal on patterns.select { ... } in a test method. Not fixed here: the fix is either a query on the catalog object or a cop change, and a cop change would alter files under mutation work.

Occurrence: four Sdlc/Structural/DomainEffectInEdge offenses in plugins/os-sdlc/test/system_model_catalog_test.rb (lines 33, 45, 49, 61) show only with the cache off Seen: bundle exec rubocop --cache false test/system_model_catalog_test.rb, from plugins/os-sdlc, on main e16fd58bd and on 380176169 (same 4 offenses at both) Run: Session 720a7477-bb8e-4373-8d74-6bbdb56f0200 (#1665 close-out) Adds: the file last changed in the tests/ to test/ rename (4ff1a393d), so the offenses are older than today's work, and the cached gate did not report them. Each flagged line is assert_empty or assert_equal on patterns.select { ... } in a test method. Not fixed here: the fix is either a query on the catalog object or a cop change, and a cop change would alter files under mutation work.
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#1173
No description provided.