diff --git a/.github/instructions/abacus-governance.instructions.md b/.github/instructions/abacus-governance.instructions.md index a8d3355f56b..820fddf9d80 100644 --- a/.github/instructions/abacus-governance.instructions.md +++ b/.github/instructions/abacus-governance.instructions.md @@ -18,8 +18,9 @@ Apply these instructions when reviewing or changing ABACUS code: Prefer explicit dependencies or narrow local interfaces. - Flag new default arguments in existing header interfaces. Prefer explicit call-site updates, overloads, or a clearer configuration object. -- Review header include growth and `.hpp` propagation carefully. These are - usually warnings unless the PR records a narrow reason. +- Review header include growth and `.hpp` propagation carefully. Do not ask + authors to replace explicit `#include` directives with forward declarations + solely to avoid header include warnings. - Require LF line endings for text files. `.bat` and `.cmd` files are the CRLF exceptions. - Flag new `#pragma once` in header files as a blocker-level governance issue. diff --git a/AGENTS.md b/AGENTS.md index 09304c46a4e..cdf49da596c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -15,7 +15,9 @@ rules. Read the complete governance document before making or reviewing changes: explain the remaining global usage. 2. Do not hide workflow switches in mutable member variables that can be changed from multiple places. - 3. Keep header dependencies minimal. + 3. Keep header dependencies clean and explicit; avoid unnecessary includes, + and do not replace `#include` directives with forward declarations just to + avoid header include warnings. 4. Avoid adding `.hpp` implementation headers or propagating them through other headers unless there is a narrow reason. 5. Do not add default arguments to existing interfaces; update call sites or @@ -230,7 +232,7 @@ full mixed-line-ending hook only for intentional repository-wide normalization. - Confirm the PR body states exact commands run, whether they passed or failed, and why any expected check could not be run. -- Keep warning rationales concrete. For example, a header include warning can be - acceptable when the header owns a value member that requires the complete type. +- Keep warning rationales concrete. For example, a header include warning is + acceptable when the header uses types declared in that header directly. - Keep historical-debt notes separate from new deterministic errors introduced by the PR. diff --git a/docs/developers_guide/agent_governance.md b/docs/developers_guide/agent_governance.md index 215a6766afd..6b64e2e68ae 100644 --- a/docs/developers_guide/agent_governance.md +++ b/docs/developers_guide/agent_governance.md @@ -46,8 +46,9 @@ focused cleanup. `PARAM`. Prefer explicit parameters or narrow local interfaces. - Do not store workflow switches in mutable member variables that can be changed implicitly from multiple places. -- Keep header dependencies minimal; avoid adding includes to headers unless the - declaration truly requires them. +- Keep header dependencies clean and explicit; avoid unnecessary includes in + headers, and do not replace `#include` directives with forward declarations + just to silence header include warnings. - Avoid adding `.hpp` implementation headers and avoid including `.hpp` files from other headers unless the PR explains why header-only implementation is needed. @@ -122,8 +123,9 @@ Deterministic errors require a code or documentation fix before merge unless a maintainer-approved exception is recorded. Deterministic warnings require a reviewable rationale or cleanup, but they do not become blockers without an explicit governance change. For header include warnings, the rationale should -state whether the header needs a complete type, for example because it owns a -value member rather than a pointer or reference. +confirm that the included header is actually used and does not introduce +unnecessary or circular dependencies; explicit `#include` directives are +preferred over replacing them with forward declarations. For global dependencies, the mechanical checker uses a PR-level budget during the legacy migration period. A PR blocks only when the number of code references diff --git a/tools/03_code_analysis/agent_governance_check.py b/tools/03_code_analysis/agent_governance_check.py index 35a5e9302a4..4cc330580e4 100644 --- a/tools/03_code_analysis/agent_governance_check.py +++ b/tools/03_code_analysis/agent_governance_check.py @@ -528,7 +528,7 @@ def check_header_include_warnings(findings: List[Finding], lines: Iterable[DiffL line.path, line.line, "Header diff adds an include dependency.", - "Confirm the declaration requires this include; prefer forward declarations where practical.", + "Confirm this include is needed by the header and does not introduce unnecessary or cyclic dependencies.", ) diff --git a/tools/03_code_analysis/test_agent_governance_check.py b/tools/03_code_analysis/test_agent_governance_check.py index c27ca617155..6441806d81e 100644 --- a/tools/03_code_analysis/test_agent_governance_check.py +++ b/tools/03_code_analysis/test_agent_governance_check.py @@ -521,6 +521,7 @@ def test_warns_for_new_header_include(self): result = self.run_checker("--base", self.base, "--head", head) self.assert_warns_with_success(result, "Header dependency review") + self.assertNotIn("forward declaration", result.stdout.lower()) def test_merge_base_scoped_comparison_excludes_base_branch_only_changes(self): self.write("source/source_base/api.h", "void update_solver(int step = 0);\n")