Skip to content

[nfc] Add IWYU guidelines to AGENTS.md, Remove rust_io_link_check - #7736

Open
fhanau wants to merge 2 commits into
mainfrom
felix/092226-build-graph
Open

fhanau wants to merge 2 commits into
mainfrom
felix/092226-build-graph

Conversation

@fhanau

@fhanau fhanau commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

[nfc] Add IWYU guidelines to AGENTS.md, move tracked-wasm-instance into its own target

[build] Remove rust_io_link_check
We already enforce this using the bazel aquery somepath check, no need to check it twice.

tracked-wasm-instance.h should be its own target anyway, moving it out facilitates some downstream improvements.
Otherwise this PR is just cleaning up and trying to teach agents about IWYU to hopefully avoid superfluous includes. We will also be adding some enforcement of not having bazel targets have unused dependencies when it would be harmful in an internal PR (!15453).

@fhanau
fhanau requested review from a team as code owners October 13, 2026 22:34
Comment thread build/AGENTS.md Outdated

## IWYU for C++ targets

By convention, there should be one wd_cc_library target for each .c++/.h file pair in most cases and

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I'm really trying to teach the agent some nuance since fully enforcing IWYU and not trying to follow it at all are likely to cause significant churn. I hope this will lead to agents not adding headers that are not needed and using implementation_deps in Bazel where appropriate?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is the best placement for this. A skill file might be better as this is likely only going to be read if the agent is doing something in the build directory.

Also, it's a bit too wordy to be effective. I'd suggest something shorter like:

## IWYU FOR C++ TARGETS

Adapted from [include-what-you-use](https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/WhyIWYU.md).
Small targets with accurate deps mean a change rebuilds and retests fewer targets.

- Don't add `#include`s a file doesn't use or `deps` a target doesn't use. When a change removes
  the last use of a header, delete its `#include`, then the dep if it's now unused.
- Put deps whose headers are included only from `.c++` files in `implementation_deps`, so they
  don't propagate to dependents.
- Prefer direct includes and deps over relying on transitive ones, but don't add a long list just
  to spell out what you already get transitively.
- Give each `.h`/`.c++` pair its own `wd_cc_library`, named after the file (e.g.
  `:tracked-wasm-instance`). A header without a `.c++` gets its own target too, with the deps it
  needs to compile on its own.
- Keep each header in exactly one target, together with its `.c++` if it has one. Exposing a
  header from a target that doesn't build its `.c++` lets code call its functions without
  depending on their definitions, which shows up later as undefined-symbol link errors.
- If splitting a pair out would create a dependency cycle, leave it in its combined target (e.g.
  `//src/workerd/io`) instead of separating the header from its `.c++`. Don't add new files to
  such targets if they can have their own.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's wordy, but I think that's needed to tell the agent that sometimes it's not possible to separate each source/header pair into its own target and that it shouldn't go ham on adding headers even though that's what IWYU means (in a strict sense). Will try to rephrase this a bit/make it shorter based on your suggestion and put it into a skill file...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually your text covers most of it, I'll probably just make minor edits

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I turned it into a skill and added two sentences to your text to (hopefully) make it not spray includes. I hope the description makes sense

@fhanau
fhanau requested a review from npaun October 13, 2026 22:35
@ask-bonk

ask-bonk Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Since last review: 0 resolved, 0 still open, 0 new.
LGTM!

Carried forward from the last review: rust-first (no author changes in their files since then; earlier findings stand)

Not re-run: api-compat, jsg-gc (no author changes in their files since the last review)


Reviewed commit: f128879e · github run

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

The generated output of @cloudflare/workers-types matches the snapshot in types/generated-snapshot 🎉

@fhanau
fhanau force-pushed the felix/092226-build-graph branch from cf332ea to f128879 Compare October 13, 2026 23:58
@codecov-commenter

codecov-commenter commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 41.04%. Comparing base (b2ff965) to head (7fc447a).
⚠️ Report is 38 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7736      +/-   ##
==========================================
+ Coverage   40.91%   41.04%   +0.13%     
==========================================
  Files         983      986       +3     
  Lines      284112   284720     +608     
  Branches    27545    27618      +73     
==========================================
+ Hits       116247   116875     +628     
+ Misses     151793   151757      -36     
- Partials    16072    16088      +16     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

We already enforce this using the bazel aquery somepath check, no need to check
it twice.
@fhanau
fhanau force-pushed the felix/092226-build-graph branch from f128879 to 7fc447a Compare October 14, 2026 19:05
@ask-bonk

ask-bonk Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Author identity unknown

*** Please tell me who you are.

Run

git config --global user.email "you@example.com"
git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: empty ident name (for runner@runnervm8k3b6.lkg1l3nnvv1ejizkdb15p355fb.gx.internal.cloudapp.net) not allowed

github run

@ask-bonk

ask-bonk Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

@fhanau Bonk workflow failed. Check the logs for details.

View workflow run · To retry, trigger Bonk again.

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.

4 participants