Skip to content

refactor(arch): extract buildpathutil to break build→rules DIP violation - #616

Merged
jeduden merged 4 commits into
mainfrom
claude/amazing-hopper-tilt2g
Jun 14, 2026
Merged

refactor(arch): extract buildpathutil to break build→rules DIP violation#616
jeduden merged 4 commits into
mainfrom
claude/amazing-hopper-tilt2g

Conversation

@jeduden

@jeduden jeduden commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • internal/build imported internal/rules/build for three path helpers (CheckGlobMatchCap, ResolvePathInRoot, UnderMdsmithDir), violating the architecture rule that only packages inside internal/rules/ may import a specific rule package
  • New internal/rules/buildpathutil package extracts those helpers; both internal/rules/build and internal/build now depend on the shared helper instead of each other
  • New contract test TestBuildDoesNotImportRulePackages guards that internal/build never again imports a rule package other than buildpathutil
  • buildpathutil added to the allowedRuleHelpers allowlist in TestRulesDoNotImportEachOther
  • Two lower-priority findings filed as plan files (engine deprecated wrappers, secreview named tests)
  • Architecture audit log updated for the 2026-06-14 sweep

Test plan

  • go test ./internal/rules/buildpathutil/... — unit tests for extracted helpers
  • go test ./internal/build/... — builder/staleness tests still pass
  • go test ./internal/integration/...TestRulesDoNotImportEachOther and TestBuildDoesNotImportRulePackages both pass
  • go test ./... — full suite green (pre-existing internal/release PGO failures excluded)
  • go run ./cmd/mdsmith check . — all Markdown passes

https://claude.ai/code/session_01PjGC2k64upbXWhKHGQXDTg


Generated by Claude Code

internal/build/builder.go and staleness.go imported internal/rules/build
for three path helpers, violating the architecture rule that only packages
inside internal/rules/ may import a specific rule package.

- New internal/rules/buildpathutil exports CheckGlobMatchCap,
  ResolvePathInRoot, and UnderMdsmithDir; tests migrated from resolve_test.go
- internal/rules/build now imports buildpathutil for UnderMdsmithDir
- internal/build imports buildpathutil instead of internal/rules/build
- TestBuildDoesNotImportRulePackages contract test guards the new boundary
- buildpathutil added to allowedRuleHelpers in TestRulesDoNotImportEachOther
- Plan files for two remaining tax items (engine wrappers, secreview tests)
- Architecture audit log entry for 2026-06-14

Closes plan/2606141910.

https://claude.ai/code/session_01PjGC2k64upbXWhKHGQXDTg
@codecov

codecov Bot commented Jun 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.49%. Comparing base (aed18aa) to head (d1abd71).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
Components Coverage Δ
Go 98.48% <100.00%> (+<0.01%) ⬆️
TypeScript 99.53% <ø> (ø)

☔ 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.

claude added 3 commits June 14, 2026 19:38
…lete empty resolve.go

Code review round 1 findings:
- staleness.go resolveOutputs lacked the .mdsmith/ output guard that
  builder.go resolveOutputs enforces; CheckStaleness/RecordBuild would
  accept a target whose outputs are under .mdsmith/ while Build would
  refuse it
- internal/rules/build/resolve.go contained only a package declaration
  after the functions were moved to buildpathutil; delete the empty file

https://claude.ai/code/session_01PjGC2k64upbXWhKHGQXDTg
Code review round 2: the UnderMdsmithDir guard added to
staleness.resolveOutputs had no test exercising it.
TestStaleness_OutputUnderMdsmithRefused verifies that CheckStaleness
returns an error when Target.Outputs contains a .mdsmith/-prefixed path.

https://claude.ai/code/session_01PjGC2k64upbXWhKHGQXDTg
…nputs

Code review round 3: builder.resolveInputs silently accepted a glob
that matched no files (only the cap check ran), while staleness.resolveInputs
correctly rejected it. A misconfigured inputs: glob would let Build
proceed with an empty input set and record a cache entry that cannot
be reproduced by CheckStaleness.

Add the same guard staleness.go has (len(matches) == 0 → error) and
cover it with TestBuild_ZeroMatchGlobIsError.

https://claude.ai/code/session_01PjGC2k64upbXWhKHGQXDTg
@jeduden jeduden added queue Add to a PR to enqueue it queue:active Applied automatically when a PR is in an active batch and removed queue Add to a PR to enqueue it labels Jun 14, 2026
@jeduden

jeduden commented Jun 14, 2026

Copy link
Copy Markdown
Owner Author

🟢 Merge Queue — picked up

This PR is in the queue and will be batched with other queue-labelled PRs.

Next: No action needed — you'll get another comment when CI starts on the batch. View merge queue run.

@jeduden

jeduden commented Jun 14, 2026

Copy link
Copy Markdown
Owner Author

🔵 Merge Queue — CI running

Merged into batch branch merge-queue/batch-616-1781468527 alongside #618. View CI run.

Next: No action needed — you'll be notified when CI completes.

@jeduden jeduden removed the queue:active Applied automatically when a PR is in an active batch label Jun 14, 2026
@jeduden
jeduden merged commit f682d63 into main Jun 14, 2026
35 checks passed
@jeduden

jeduden commented Jun 14, 2026

Copy link
Copy Markdown
Owner Author

Merge Queue — merged

This PR landed on main via commit 03b0e91. CI run that validated the merge.

Next: Done — nothing more to do here.

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.

2 participants