Skip to content

Replace plugin root regex with SafeDIRootScanner#203

Merged
dfed merged 7 commits intomainfrom
dfed/root-scanner
Apr 3, 2026
Merged

Replace plugin root regex with SafeDIRootScanner#203
dfed merged 7 commits intomainfrom
dfed/root-scanner

Conversation

@dfed
Copy link
Copy Markdown
Owner

@dfed dfed commented Mar 31, 2026

Summary

  • add a lightweight SafeDIRootScanner executable that performs lexical root discovery without SwiftSyntax
  • make both build plugins invoke the scanner to produce SafeDIManifest.json plus the explicit per-root output file list before returning buildCommand
  • keep SafeDITool's manifest contract unchanged while removing regex-based root discovery and manifest writing from the plugin layer
  • make duplicate root file basenames deterministic and collision-safe in the scanner output naming logic
  • align SafeDIToolTests with the real plugin path by generating manifests through the scanner while preserving the existing input Swift -> expected output style
  • add scanner-focused tests for comment/string/raw-string skipping, deterministic manifest serialization, and duplicate-basename outputs
  • add tool regressions for same-file multi-root exact output and duplicate-basename manifest outputs

Why

buildCommand is still required here for incremental performance and compatibility with build systems like Buck and Bazel, which means the plugin has to know its explicit output files up front. #202 introduced the manifest contract and per-root outputs, but its plugin-side root discovery remained regex-driven.

This PR keeps the fast explicit-output path while tightening the weakest part of the stack:

  • the plugin now orchestrates instead of guessing
  • the scanner owns cheap lexical discovery and manifest generation
  • SafeDITool remains the semantic source of truth for validation and code generation

Validation

  • swift test
  • ./lint.sh

Stack

  • base: #202
  • this PR stays draft until the full stack is ready

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.92%. Comparing base (e801810) to head (1c60ca3).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #203      +/-   ##
==========================================
- Coverage   99.94%   99.92%   -0.03%     
==========================================
  Files          37       40       +3     
  Lines        3498     3809     +311     
==========================================
+ Hits         3496     3806     +310     
- Misses          2        3       +1     
Files with missing lines Coverage Δ
Sources/SafeDIRootScanner/RelativePath.swift 100.00% <100.00%> (ø)
Sources/SafeDIRootScanner/RootScanner.swift 100.00% <100.00%> (ø)
...s/SafeDIRootScanner/SafeDIRootScannerCommand.swift 100.00% <100.00%> (ø)
Sources/SafeDITool/SafeDITool.swift 99.65% <100.00%> (-0.35%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dfed dfed force-pushed the dfed/root-scanner branch from a3aab3e to efccd3e Compare April 2, 2026 16:48
@dfed dfed self-assigned this Apr 2, 2026
@dfed dfed marked this pull request as ready for review April 2, 2026 22:39
@dfed dfed force-pushed the dfed/per-root-output branch from f6229a1 to 6fe9436 Compare April 3, 2026 07:00
@dfed dfed force-pushed the dfed/root-scanner branch from acf381f to 1e1e014 Compare April 3, 2026 07:01
Base automatically changed from dfed/per-root-output to main April 3, 2026 07:12
dfed and others added 7 commits April 3, 2026 00:12
…lpers

- Extract relativePath into RelativePath.swift using standardizedFileURL
  for consistent path resolution across CSV writing and manifest generation
- Move writeInputSwiftFilesCSV and runRootScanner into SharedRootScanner.swift,
  symlinked only into plugins that perform scanning
- Remove RootScanner.swift symlink from InstallSafeDITool (unused)
- Replace force unwrap in outputFileNames with dictionary default
- Fix Linux CI: add isDirectory to ScannerFixture URL construction
- Document SafeDIRootScanner target purpose for non-SPM build systems

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dfed dfed force-pushed the dfed/root-scanner branch from 1e1e014 to 1c60ca3 Compare April 3, 2026 07:13
@dfed dfed merged commit 3a877fd into main Apr 3, 2026
17 checks passed
@dfed dfed deleted the dfed/root-scanner branch April 3, 2026 07:13
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.

1 participant