Skip to content

Remove stray dbg! from the privacy checker - #50

Merged
dduugg merged 1 commit into
mainfrom
remove-stray-dbg-in-privacy-checker
Aug 19, 2026
Merged

dduugg merged 1 commit into
mainfrom
remove-stray-dbg-in-privacy-checker

Conversation

@dduugg

@dduugg dduugg commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #49.

The bug

src/packs/checker/privacy.rs:64 carried a live dbg!:

dbg!(constant_is_private, constant_is_in_private_namespace);

It fired once per reference checked against a pack's private_constants, in released builds as well as debug, writing two lines to stderr each time and leaking internal file and line numbers into user-facing output.

The fix is deleting the line. src/ now contains no dbg! at all.

Why it survived

Nothing in the suite reached the branch — no fixture configured private_constants. On main, grep -rl private_constants tests/fixtures/ returned nothing, against three hits under src/.

So this adds tests/fixtures/privacy_violations_with_private_constants, exercising all three combinations of the two flags the dbg! was printing:

Reference Flags Expected
::Bar constant_is_private violation
::Bar::Inner constant_is_in_private_namespace violation
::SomeConcern neither no violation

The third row is the one worth having. A non-empty private_constants list narrows privacy to that list, so anything in the pack but absent from it stays public — behaviour that previously had no coverage.

test_check_with_private_constants asserts those three outcomes and that stderr is empty, so the dbg! can't return unnoticed.

Verification

I checked the test actually guards the regression rather than merely passing: with the dbg! reinstated it fails on the stderr assertion, reporting all 6 noise lines; with the line removed it passes.

cargo fmt --all -- --check                  clean
cargo clippy --all-targets --all-features   clean
cargo test --test check_test                26 passed

Note on the audit check

The failing audit job is unrelated to this change and pre-dates it. actions-rs/audit-check@v1 cannot compile cargo-audit: the pinned toolchain is rustc 1.92.0 and kstring@2.0.4 now requires 1.96.0. That action has been unmaintained for years (it targets Node 12 and the workflow still pins actions/checkout@v2), and the workflow has never completed successfully on this repo — every earlier run is action_required. This diff touches no Cargo.toml or Cargo.lock, so it cannot affect that job. Being addressed separately.

Sent with Claude Code

`privacy.rs` carried a live `dbg!` on the `private_constants` branch, so any
pack configured with `private_constants` emitted two lines to stderr per
checked reference, in released builds as well as debug. It also leaked
internal file and line numbers into user-facing output.

No fixture configured `private_constants`, so nothing exercised the branch.
Add `tests/fixtures/privacy_violations_with_private_constants`, covering all
three combinations of the two flags the `dbg!` was printing:

  ::Bar         listed in private_constants  -> violation
  ::Bar::Inner  inside the private namespace -> violation
  ::SomeConcern absent from the list         -> no violation

The last case is the one that had no coverage: a non-empty
`private_constants` list narrows privacy to that list, leaving everything
else in the pack public.

`test_check_with_private_constants` asserts those outcomes and that stderr
is empty, so the `dbg!` cannot come back unnoticed.

Fixes #49
@dduugg
dduugg requested a review from a team as a code owner August 19, 2026 18:20
@github-project-automation github-project-automation Bot moved this to Triage in Modularity Aug 19, 2026
@dduugg
dduugg enabled auto-merge (squash) August 19, 2026 18:31
@dduugg
dduugg merged commit 8250ba5 into main Aug 19, 2026
11 of 12 checks passed
@dduugg
dduugg deleted the remove-stray-dbg-in-privacy-checker branch August 19, 2026 18:41
@github-project-automation github-project-automation Bot moved this from Triage to Done in Modularity Aug 19, 2026
dduugg added a commit that referenced this pull request Sep 26, 2026
Retitle `## Unreleased` to `## 0.5.0`, since cargo-dist builds the GitHub
Release notes by matching that heading against the tag, and drop the
reminder comment #45 left for whoever cut this release.

Add entries for the other user-visible changes since v0.4.0: the
recorded-violation matching fix in strict packs (#43), the stray `dbg!` in
the privacy checker (#50), the inflector regex speedup (#54), and the switch
to cargo-dist release artifacts (#33).
@dduugg dduugg mentioned this pull request Sep 26, 2026
7 of 11 tasks
dduugg added a commit that referenced this pull request Sep 27, 2026
* Bump version to 0.5.0

The strict-mode change in #45 is breaking, and pre-1.0 that wants a minor
bump rather than 0.4.x.

Also rewrite INSTALLATION.md for the cargo-dist release artifacts. 0.5.0 is
the first release through cargo-dist (#33), which publishes installer
scripts and per-target archives but no dotslash `pks` file. And
`cargo install pks` has only ever installed the original alexevanczuk/packs
crate from crates.io, not this repository.

* Prepare the CHANGELOG for 0.5.0

Retitle `## Unreleased` to `## 0.5.0`, since cargo-dist builds the GitHub
Release notes by matching that heading against the tag, and drop the
reminder comment #45 left for whoever cut this release.

Add entries for the other user-visible changes since v0.4.0: the
recorded-violation matching fix in strict packs (#43), the stray `dbg!` in
the privacy checker (#50), the inflector regex speedup (#54), and the switch
to cargo-dist release artifacts (#33).

* Restore the DotSlash file on releases

#33 replaced ci.yml's release jobs with cargo-dist and dropped the
generate-dotslash-files job along with them, so 0.5.0 would have been the
first release without a DotSlash `pks` file.

cargo-dist creates the GitHub Release with GITHUB_TOKEN, and events from
GITHUB_TOKEN don't trigger other workflows, so this can't be a separate
`on: release` workflow. Instead, publish-dotslash.yml is a reusable workflow
that dist calls once the release is announced (`post-announce-jobs` in
dist-workspace.toml), and release.yml is regenerated with `dist generate` to
add that call.

dotslash-config.json now matches cargo-dist's asset names exactly. The
tarballs put the binary under a `pks-<target>/` directory, the Windows zip is
flat, and Windows is new. zizmor's secrets-inherit and self-repository
findings come from dist's template for the call, so they're ignored for
release.yml alongside the existing ones.

Checked locally by running the action's process_config.py, at the pinned
commit, against a real cargo-dist archive for aarch64-apple-darwin, then
running the generated file with dotslash 0.5.9, which printed `pks 0.5.0`.

* Note DotSlash re-run recovery, pin the CHANGELOG link

dotslash-publish-release uploads without --clobber, so re-running the job
once the `pks` asset is on the release fails. Say how to clear it in the
workflow's header.

The 0.5.0 CHANGELOG section becomes the release body, so link the
INSTALLATION.md that shipped with it rather than main's.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Live dbg! in privacy.rs writes to stderr in released builds when private_constants is configured

2 participants