Add cop Sdlc/Sequel/InlineDatasetQuery #911
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#911
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
A query on one model's rows is built outside that model.
Signal: a query on one model's rows is built outside that model, so it has no name and no owner.
Approach
Add the cop
Sdlc/Sequel/InlineDatasetQueryunderplugins/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:
where filter exclude or order order_by reverse reverse_order limit offset group havingcalled on a*_datasetchain outside adataset_module.Not flagged: Left out on purpose (rare, or a hit does not always need a correction): join family,
selectfamily,distinct,with_sql,where_all/where_each/where_single_value,first(conditions),eager/eager_graph,invert unordered unfiltered for_update.Known hits:
model/implementation/dispatching.rb:9-10(where(verdict: "pass")),reroute/draft.rb:29,model/implementation/progress_witness.rb:24(reverse) (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.where(status: "shipped"), afterorders_dataset.shipped.Depends on #908 (Lesson concept move;
Lesson::Libraryreads the plugin lesson directory).Required work:
InlineDatasetQueryinplugins/os-sdlc/lib/os_sdlc/cops/*.rbThe signalinplugins/os-sdlc/lint-lessons/sdlc-sequel-inline-dataset-query.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-911 through the os-sdlc pipeline.
Resolution
Done: Cop Sdlc/Sequel/InlineDatasetQuery added and enabled, with its lesson file plugins/os-sdlc/lint-lessons/sdlc-sequel-inline-dataset-query.md. Seven existing hits corrected by delegation to named dataset_module methods on Dispatch, StepResult, Reroute, and Violations.
Evidence: Branch ticket-911; os-sdlc implementation 17: 10 dispatches. suite-check escalated once with green_report_nonzero_exit (all tests passed, wall time 64.6 s, load average 9.03); after the load dropped, a reroute re-entered at suite-check and the suite passed in 17.5 s. Required-work gate green, contract-auditor pass.
Follow-ups: Lesson converts to YAML under #913. History row added after merge.