Skip to content

Replace plugin root regex with SafeDIRootScanner#203

Draft
dfed wants to merge 5 commits intodfed/per-root-outputfrom
dfed/root-scanner
Draft

Replace plugin root regex with SafeDIRootScanner#203
dfed wants to merge 5 commits intodfed/per-root-outputfrom
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 (f6229a1) to head (8a8c8e1).

Additional details and impacted files

Impacted file tree graph

@@                  Coverage Diff                   @@
##           dfed/per-root-output     #203    +/-   ##
======================================================
  Coverage                 99.91%   99.92%            
======================================================
  Files                        37       40     +3     
  Lines                      3501     3838   +337     
======================================================
+ Hits                       3498     3835   +337     
  Misses                        3        3            
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.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

dfed and others added 4 commits March 31, 2026 09:07
…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>
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