Skip to content

Add the AGENTS.md details that cost time to rediscover - #1120

Open
tas50 wants to merge 1 commit into
chef:mainfrom
tas50:agents_md_field_notes
Open

Add the AGENTS.md details that cost time to rediscover#1120
tas50 wants to merge 1 commit into
chef:mainfrom
tas50:agents_md_field_notes

Conversation

@tas50

@tas50 tas50 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

AGENTS.md deliberately points at DEVELOPER_GUIDE.md and WRITING_RULES.md instead of duplicating them. This adds only the things that are in none of the three and that you find by hitting them.

What was added

A cop's name comes from its module nesting, not its file path. rake validate_config walks the constants under RuboCop::Cop::Chef, so the directory is convention. The guides write the path as <department>, which holds for six of the eight directories and not for these:

Directory Department
lib/rubocop/cop/chef/deprecation/ Chef/Deprecations
lib/rubocop/cop/chef/redundant/ Chef/RedundantCode
lib/rubocop/cop/inspec/deprecation/ InSpec/Deprecations
lib/rubocop/cop/chefstyle/ruby/ Chef/Ruby, validated against config/chefstyle.yml

rake generate_cops_yml_documentation is not idempotent on current Ruby. On a clean checkout it rewrites 12 files with whitespace-only changes: Psych 5.3 stopped emitting a trailing space after an empty examples: or version_added: key, and those files were generated before that. An agent following the documented "run this after adding a cop" step gets 12 files of churn mixed into their diff. Documented with a way out (git checkout -- docs-chef-io/ after staging your own file) rather than fixed, since regenerating is a whitespace-only commit across the generated tree — happy to send that separately if wanted.

CI runs linelint over every file, rake style only over Ruby. Layout/TrailingEmptyLines covers .rb, but a config/cookstyle.yml entry or a Markdown file missing its trailing newline passes rake and fails on the PR.

Smaller ones: the negative-case rule is enforced by spec/negative_case_coverage_spec.rb, so it fails as a repo-wide list of paths rather than in your own spec; Chef/Effortless is slated for removal so new cops shouldn't go there; and new cop files need no require, since lib/cookstyle.rb globs the tree.

Labels can't be applied from a fork. gh pr create --label opens the PR and then fails on AddLabelsToLabelable, which reads like the whole command failed and invites a retry that would open a second PR.

Verification

  • bundle exec rake exits 0 — 1239 examples, 0 failures; validate_config clean. The 11 refactor-severity offenses rake style reports are pre-existing on main (identical with this change stashed) and don't affect the exit code.
  • Every claim checked against the tree: the department mapping from module nesting, the generator drift by running it and reverting, the linelint gap by confirming cookstyle --list-target-files returns 0 Markdown/YAML files out of 567.
  • AGENTS.md ends in exactly one newline.

Labels

I don't have write access, so I couldn't apply these: Aspect: Documentation, Expeditor: Skip All.

Unrelated things noticed, not touched

Per the Scope section of AGENTS.md, flagging rather than fixing:

  1. tasks/prof.rake:14Rake::Task[:run] is a global lookup, not namespaced, so rake prof:slow_cops and rake prof:walk abort with Don't know how to build task 'run'. Should be Rake::Task['prof:run']. DEVELOPER_GUIDE.md documents both as working.
  2. Rakefile — the RSpec task sets spec.pattern = FileList['spec/cop/**/*.rb'], but specs live in spec/rubocop/cop/. It is inert today: the empty FileList makes RSpec::Core::RakeTask omit --pattern, so rspec falls back to spec/ and runs everything. Worth knowing that a naive fix to spec/rubocop/cop/**/*_spec.rb would silently drop spec/negative_case_coverage_spec.rb.
  3. cookstyle.gemspecrequired_ruby_version = '>= 2.7' while CI tests 3.1, 3.4, and 4.0.

AGENTS.md points at DEVELOPER_GUIDE.md and WRITING_RULES.md rather than
duplicating them, which is right, but a few things aren't in any of the three
and are the kind of thing you only find by hitting them.

- A cop's name comes from its module nesting, not its file path. The guides
  write the path as `<department>`, which is accurate for six of the eight
  directories and wrong for `deprecation/` (Chef/Deprecations) and
  `redundant/` (Chef/RedundantCode). Added the mapping table, including the
  chefstyle tree, whose cops are named Chef/Ruby and validate against
  config/chefstyle.yml.
- `rake generate_cops_yml_documentation` is not idempotent on current Ruby.
  Psych 5.3 stopped emitting a trailing space after empty `examples:` and
  `version_added:` keys, so the task rewrites 12 files that predate the change
  and belong to nobody's PR. Documented rather than regenerated, since the fix
  is a whitespace-only commit across the generated tree.
- CI runs linelint over every file; `rake style` only inspects Ruby. A YAML or
  Markdown file missing its trailing newline passes locally and fails on the PR.
- The negative-case requirement is enforced by a repo-wide spec, so it fails as
  a list of paths rather than in the spec you just wrote. Named the file.
- Chef/Effortless is slated for removal, so new cops shouldn't go there.
- Labels can't be applied from a fork; `gh pr create --label` opens the PR and
  then fails on AddLabelsToLabelable, which reads like the PR failed too.

Verified: `bundle exec rake` exits 0 (1239 examples, 0 failures; the 11
refactor-severity offenses are pre-existing on main and unchanged here). Every
claim was checked against the tree rather than inferred, and AGENTS.md ends in
a single newline for linelint.

Signed-off-by: Tim Smith <tsmith84@proton.me>
@tas50
tas50 requested review from a team and jaymzh as code owners August 24, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant