Add cop Sdlc/Sequel/RubyFilterAfterAll #910
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#910
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
Rows are loaded, then filtered in Ruby.
Signal: rows are loaded, then filtered in Ruby; the filter is a query that belongs to the owning model.
Approach
Add the cop
Sdlc/Sequel/RubyFilterAfterAllunderplugins/os-sdlc/lib/os_sdlc/cops/.Templates:
registry_outside_entry_point.rb,row_index_on_model.rb, and the sharedsequel_allowed_paths.rb.Authoring guide:
plugins/os-sdlc/skills/mine-lints/references/implement-cop.md.RuboCop runs with
DisabledByDefault: true, so every enabled cop blocks at the gate and every hit must always need a correction.Do not widen the match lists below.
Receiver test: the chain starts from a
*_datasetcall.Direct model queries (
Model.where) are out of scope.Flagged:
.allor.to_aon a*_datasetchain followed byfind detect select filter find_all reject filter_map partition, or by the block forms ofcount any? none? all?. The materializer is required, because Sequel's ownselecton a dataset picks columns.Not flagged:
entries; directeach/mapon a dataset;grep sort_by group_by min_by max_by uniq sum first(n) take.Known hits:
model/implementation.rb:78,model/implementation.rb:97-98(.all.select(&:green?)),model/implementation/progress_witness.rb:29(all underplugins/os-sdlc/lib/os_sdlc/).Correct the existing hits in
plugins/os-sdlc/lib/in the same change.Intended correction: move the query or decision into a named
dataset_modulemethod on the model that owns the rows, and delegate from the caller.Lesson (ADR-0265): the lesson file is a required part of the cop.
Path:
plugins/os-sdlc/lint-lessons/<kebab-cop-name>.mdin the plugin (ADR-0266).Sections in order: The signal; What it is a sign of; Why it matters; Your decision; Correction; Example.
Lesson text uses generic names (for example
orders_dataset,Order), never names from this codebase.Lesson example: before
orders_dataset.all.select(&:shipped?), afterorders_dataset.shipped.Depends on #908 (Lesson concept move;
Lesson::Libraryreads the plugin lesson directory).Required work:
RubyFilterAfterAllinplugins/os-sdlc/lib/os_sdlc/cops/*.rbThe signalinplugins/os-sdlc/lint-lessons/sdlc-sequel-ruby-filter-after-all.mdAcceptance criteria
*_datasetchain, when the cop runs, then it flags it.plugins/os-sdlc/lib, when the gate runs, then none remain.Owner sketch
Origin
Work started on branch ticket-910 through the os-sdlc pipeline.
Resolution
Done: Cop Sdlc/Sequel/RubyFilterAfterAll added and enabled, with its lesson file plugins/os-sdlc/lint-lessons/sdlc-sequel-ruby-filter-after-all.md. Three existing hits corrected by delegation to Reroute and StepResult dataset_module methods.
Evidence: Branch ticket-910; os-sdlc implementation 16: 11 dispatches, 1 retry (suite-check failed once, programmer-repair, suite green on the second check), required-work gate green, contract-auditor pass. Implementation 14 was abandoned after Map::ChangedError; its state is kept on branch ticket-910-run14-wip.
Follow-ups: Lesson converts to YAML under the Lesson YAML ticket (to be captured). Capture a workflow ticket: a map change merged by another session stops an in-flight run with Map::ChangedError. History row added after merge.