Write lessons for the ClassLength family cops #1323
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#1323
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
Lessons guide the agent when a cop fires. The ClassLength family has cops with no lesson (ModuleOwnsInstanceState, DuplicatedStatementSequence) and cops not yet built (the repeated-method-skeleton cop
Sdlc/Dry/RepeatedRescueClause, #1321, and the repeated-collaborator-construction copSdlc/Dry/RepeatedCollaboratorConstruction, #1322). plugins/os-sdlc/lint-lessons/metrics-class-length.yml (commita830d451) covers only one cause: the same work written many times. Its correction contradicts the shipped split into job-named classes (IssueCommands, ProjectCommands).Reproduce
n/a: missing prose artifacts.
Approach
Write lessons in plugins/os-sdlc/lint-lessons/*.yml. A lesson uses no repo-specific names.
Rewrite metrics-class-length.yml by cause:
Add one lesson each for Sdlc/Dry/RepeatedRescueClause (#1321), Sdlc/Dry/RepeatedCollaboratorConstruction (#1322), Sdlc/Structural/ModuleOwnsInstanceState, and Sdlc/Dry/DuplicatedStatementSequence.
This ticket is blocked by #1321 and #1322.
The two new-cop lessons take their content from the smell analyses in docs/plans/class-length-family/: smell-repeated-method-skeleton.md sections 5, 10, 13 (wrapper fix, forms A and B) and smell-repeated-collaborator-construction.md sections 5, 7, 10 (the
build_<class>fix, its name check, the three memoization checks as a note indecision, and the false-positive ticket as the escape path).The #1325 audit (docs/plans/class-length-family/sdlc-cop-audit.md) found false-positive shapes for Sdlc/Dry/DuplicatedStatementSequence (#1345: windows of local assignments the caller reads later; windows in two different classes) and Sdlc/Structural/ModuleOwnsInstanceState (#1372: a module with
extend selformodule_function, whose ivars are state on the module object). Their lessons name those shapes indecisionas cases to report through a false-positive ticket, not to fix.Each lesson file has the fields that
OsSdlc::Lesson.fromrequires: key, signal, sign_of, why, decision, correction, example (before, after).Lesson::Catalogfinds a lesson by a file name made from its key, for exampleSdlc/Dry/RepeatedRescueClause-> sdlc-dry-repeated-rescue-clause.yml.Required work:
Several jobsinplugins/os-sdlc/lint-lessons/metrics-class-length.ymlkey: Sdlc/Dry/RepeatedRescueClauseinplugins/os-sdlc/lint-lessons/sdlc-dry-repeated-rescue-clause.ymlkey: Sdlc/Dry/RepeatedCollaboratorConstructioninplugins/os-sdlc/lint-lessons/sdlc-dry-repeated-collaborator-construction.ymlkey: Sdlc/Structural/ModuleOwnsInstanceStateinplugins/os-sdlc/lint-lessons/sdlc-structural-module-owns-instance-state.ymlkey: Sdlc/Dry/DuplicatedStatementSequenceinplugins/os-sdlc/lint-lessons/sdlc-dry-duplicated-statement-sequence.ymlAcceptance criteria
Owner sketch
Prose only; no Ruby object changes. Files written in plugins/os-sdlc/lint-lessons/:
The readers stay as they are:
OsSdlc::Lesson.from(path, data)validates the fields andOsSdlc::Lesson::Catalog#lesson(key)loads the file;OsSdlc::Lesson::Relay#render(keys)renders it. Test for criterion 2: one Relay render per key withLesson::Catalog.default.Origin
VERDICT: CREATE
Blocked by #1321 and #1322: the lessons for the new cops need the cops to exist.
Work started on branch ticket-1323 through /os-sdlc:implement.
Resolution
Done: Rewrote lint-lessons/metrics-class-length.yml by six causes with one correction each, and added lessons for Sdlc/Dry/RepeatedRescueClause, Sdlc/Dry/RepeatedCollaboratorConstruction, Sdlc/Structural/ModuleOwnsInstanceState and Sdlc/Dry/DuplicatedStatementSequence. The last two name the #1325 false-positive shapes as cases to report.
Evidence: Commit
3a159229. New test tests/lesson/class_length_family_lessons_test.rb was red before the lesson files existed (all four keys false) and is green now. Full os-sdlc suite: 2648 runs, 0 failures, 0 errors. Rubocop on the new test: no offenses. Criterion 3 grep over the five files: no match. One design audit (opus reviewer): verdict pass; its three items were fixed (bare-rescue group, private_class_method case, assert-window skip).Follow-ups: Occurrence on #812: implementation-open refuses category/prose-artifact tickets, so this ticket ran outside the pipeline. Suite wall time 61.3 s over the 60 s budget is already #1341. Dropped: one-word scope note (blocks, sclass) in the RescueClause signal; the lesson's class-or-module wording covers the usual case.