Skip to content

docs: plan to route exclusion-match messages through logging (quiet library, unchanged CLI)#592

Closed
kmcquade wants to merge 2 commits into
masterfrom
docs/exclusion-logging-plan
Closed

docs: plan to route exclusion-match messages through logging (quiet library, unchanged CLI)#592
kmcquade wants to merge 2 commits into
masterfrom
docs/exclusion-logging-plan

Conversation

@kmcquade

Copy link
Copy Markdown
Collaborator

What

Adds docs/plans/2026-06-14-exclusion-message-logging.md — a reviewed implementation plan (no source changes) for making the Excluded prefix: / Excluded suffix: lines from is_name_excluded quiet for library consumers while keeping CLI output byte-for-byte identical.

Why

cloudsplaining/shared/exclusions.py::is_name_excluded() emits prefix/suffix matches via utils.print_grey (a raw print()), bypassing logging entirely. These fire during collection construction (RoleDetailList / ManagedPolicyDetails) for every service-linked role / AWS-managed policy — so any library parse of get-account-authorization-details floods stdout, with no way to silence it via standard logging. The exact-match branch already uses logger.debug; only prefix/suffix are inconsistent.

Proposed approach (in the doc)

  • exclusions.py: route prefix/suffix through a _report_exclusion() helper — logger.debug by default (library), print_grey when a module-level toggle is on.
  • bin/cli.py: the Click group callback scopes the toggle on for the CLI invocation and restores the prior value via ctx.call_on_close() — so CLI output is unchanged and nothing leaks back into a later in-process library call.
  • TDD-first, including an embedded-CLI regression test and an autouse reset fixture.

Review trail

  • Opus fact-checkyes-with-fixes (root cause, trigger paths, download claim, CLI chokepoint, import safety, no test breakage all confirmed; 3 fixes folded in).
  • Codex adversarial reviewneeds-attention: flagged the v1 sticky-global toggle as a library-mode leak. Resolved in v2 via the scoped ctx.call_on_close() restore + regression test.

Scope

Plan doc only — no production code changes. Implementation will follow in a separate PR.

🤖 Generated with Claude Code

kmcquade and others added 2 commits June 14, 2026 17:00
Add docs/plans/exclusion-message-logging.md: make the "Excluded prefix/suffix"
lines from is_name_excluded quiet for library consumers (logger.debug) while
keeping CLI output byte-for-byte identical via a module-level toggle the CLI
group callback flips on. Fact-checked by an Opus review subagent (verdict:
yes-with-fixes); the three required fixes are folded in.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
v2 of the plan. The Codex adversarial review (verdict: needs-attention) flagged
the v1 sticky process-global toggle: an in-process caller that runs the CLI and
then uses the library would keep printing exclusion matches, violating the
quiet-by-default library contract.

Fix: scope set_exclusion_output(True) to the Click invocation and restore the
prior value via ctx.call_on_close(); set_exclusion_output now returns the
previous value. Add an embedded-CLI regression test (TDD item 5) that runs the
CLI in-process then asserts the library is quiet afterward.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@kmcquade

Copy link
Copy Markdown
Collaborator Author

Superseded: the plan doc has been folded into the implementation branch feat/exclusion-message-logging so the plan and the code ship together in a single PR. Closing this plan-only PR; no content is lost.

@kmcquade kmcquade closed this Jun 14, 2026
@kmcquade kmcquade deleted the docs/exclusion-logging-plan branch June 14, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant