Skip to content

fix(canonical): apply .gitignore consistently across publisher and consumer content-hash walks - #1205

Open
detail-app[bot] wants to merge 3 commits into
mainfrom
detail/bug-fix/fix-canonical-apply-gitignore-consistently-across-dad930
Open

detail-app[bot] wants to merge 3 commits into
mainfrom
detail/bug-fix/fix-canonical-apply-gitignore-consistently-across-dad930

Conversation

@detail-app

@detail-app detail-app Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Detail bug report: View on Detail

Bug

pcb-canonical computes a BLAKE3 content hash over a package's files, recorded by pcbc publish in an annotated git tag and recomputed by pcb-zen's resolver over the fetched package, which bails (verify_tag_hashes) if the two differ. The walker used ignore::WalkBuilder with defaults, so committed .gitignore rules were only applied when a .git/.jj directory existed above the walked root (ignore's default require_git(true)): the publisher walks inside the workspace git repo (.git present → .gitignore applied), while the consumer walks a git archive extract (.git absent → .gitignore ignored). For a tracked file matching a committed .gitignore rule (e.g. a force-added debug.log against *.log, or a file committed before being added to .gitignore), the two walks saw different file sets, so the hashes diverged and every consumer's verification failed — the package became unresolvable.

Fix

Set the walker to .require_git(false) so committed .gitignore is applied regardless of whether .git is present, and .git_global(false) / .git_exclude(false) to ignore the per-machine global gitignore and .git/info/exclude (neither is part of the committed tree and git archive ignores both, so honoring them was itself a divergence source). git_ignore(true) stays the default, so committed .gitignore is now honored identically on both sides — preserving the documented "Respect .gitignore" canonicalization rule — while the hash becomes environment-independent and matches what git archive actually emits.

Added a regression test (publisher_and_consumer_hashes_agree_for_tracked_but_ignored_file) that runs a real git round-trip: it force-adds debug.log against a *.log .gitignore, commits, hashes the in-repo dir as the publisher, extracts git archive HEAD into a .git-less tempdir as the consumer, and asserts both sides drop debug.log and produce equal hashes. This is the only test that exercises the publisher side with a real .git, closing the gap that let this bug go undetected.

Testing

  • New regression test for the publisher/consumer hash divergence passes; the existing gitignore_patterns snapshot test now reflects .gitignore being applied in a non-git tempdir (the snapshot was updated to drop the previously-included ignored files — please review and approve that snapshot change).
  • Full pcb-zen suite passes (112/112), including all other canonical snapshot tests (golden hash stability, nested-package exclusion, pcb.sum exclusion, single-file hashing, determinism).
  • Workspace typecheck, clippy (-D warnings), and cargo fmt --check are clean; doctests pass.
  • Publisher end-to-end pcbc tests (publish/release/tag) pass where the layout pipeline is not required; the remaining pcbc failures in this sandbox are pre-existing KiCad-version incompatibilities (footprint-library format and missing kicad-cli pcb drc/erc subcommands — the environment has KiCad 7.0.11, CI uses 10.0.5). A baseline comparison (same tests with the fix reverted under the same KiCad 7) produced the identical failures, confirming no regressions from this change.

Automatic Fixes PRs can be configured here.


Note

Medium Risk
Changes which files enter content hashes, so previously published tags can disagree until republished; this directly affects publish verification and dependency resolution integrity.

Overview
Aligns package content hashing so publish-time walks in a git repo and consumer walks over git archive extracts see the same files.

The canonical WalkBuilder now applies only package-local .gitignore / .ignore (.parents(false), .require_git(false)) and skips ancestor rules, global gitignore, and .git/info/exclude. That removes hash mismatches that broke tag verification when committed ignore rules were honored on one side but not the other.

Adds a git round-trip regression test (in-repo package dir vs archive extract) and updates the gitignore_patterns snapshot to match ignore behavior in non-git tempdirs. Docs and changelog note that older published hashes tied to ancestor or machine-local excludes may need a new package version.

Reviewed by Cursor Bugbot for commit 7cd15fb. Bugbot is set up for automated code reviews on this repo. Configure here.

@detail-app
detail-app Bot requested a review from LK September 6, 2026 02:24
@detail-app detail-app Bot assigned LK Sep 6, 2026
@detail-app detail-app Bot added the detail label Sep 6, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

cursor[bot]

This comment was marked as resolved.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale comment

Left a non-blocking comment; no reviewers assigned. Cursor Bugbot’s check skipped and its review reported an unresolved finding, so this is not approved. The content-hash walker change is also not a small fixup.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@akhilles
akhilles force-pushed the detail/bug-fix/fix-canonical-apply-gitignore-consistently-across-dad930 branch from 026e3e0 to 29008fb Compare September 7, 2026 04:19

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale comment

Left a non-blocking comment; no reviewers assigned. Cursor Bugbot’s check skipped, so this is not approved. The content-hash walker change is also not a small fixup.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@akhilles
akhilles force-pushed the detail/bug-fix/fix-canonical-apply-gitignore-consistently-across-dad930 branch from 29008fb to edecdef Compare September 7, 2026 14:13
cursor[bot]

This comment was marked as resolved.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale comment

Left a non-blocking comment; no reviewers assigned. Cursor Bugbot’s check skipped, so this is not approved. The content-hash walker change is also not a small fixup.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@akhilles
akhilles force-pushed the detail/bug-fix/fix-canonical-apply-gitignore-consistently-across-dad930 branch from edecdef to 811d00a Compare September 7, 2026 15:21

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale comment

Left a non-blocking comment; no reviewers assigned. Cursor Bugbot passed with no unresolved findings that need human review (Security Agent was not running). This is not approved because the content-hash walker change is not a small fixup.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@akhilles
akhilles force-pushed the detail/bug-fix/fix-canonical-apply-gitignore-consistently-across-dad930 branch from 811d00a to 69330a8 Compare September 7, 2026 16:01

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale comment

Left a non-blocking comment; no reviewers assigned. Cursor Bugbot passed with no unresolved findings that need human review (Security Agent was not running). This is not approved because the content-hash walker change is not a small fixup.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@detail-app
detail-app Bot force-pushed the detail/bug-fix/fix-canonical-apply-gitignore-consistently-across-dad930 branch from 69330a8 to 7cd15fb Compare September 8, 2026 06:25

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7cd15fb. Configure here.

.parents(false)
.require_git(false)
.git_global(false)
.git_exclude(false)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ancestor ignore skip hashes local junk

High Severity

.parents(false) stops the publisher from applying workspace .gitignore rules, so untracked files that Git ignores at the repo root are hashed. Consumers unpack git archive and never see those files, so verification fails and the package cannot be resolved.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7cd15fb. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Left a non-blocking comment; no reviewers assigned. Cursor Bugbot’s check skipped, so this is not approved. The content-hash walker change is also not a small fixup.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants