Skip to content

fix: make dotfile loading optional, defaulting to off#112

Open
silug wants to merge 3 commits intosimp:mainfrom
silug:fix/dotfile-loading
Open

fix: make dotfile loading optional, defaulting to off#112
silug wants to merge 3 commits intosimp:mainfrom
silug:fix/dotfile-loading

Conversation

@silug
Copy link
Copy Markdown
Contributor

@silug silug commented Apr 21, 2026

When loading via Dir.glob on a real filesystem, Ruby's glob engine skips hidden files and directories (those starting with '.') because the default '*' pattern does not match dot-prefixed names. The zip filesystem adapter (rubyzip's Zip::FileSystem) does not share this behaviour and could return dotfiles from its glob, leading to inconsistent results depending on how the environment was loaded.

Add a load_dotfiles: keyword argument (default: false) to ModuleLoader and thread it through EnvironmentLoader. When false, any file whose path relative to the compliance_profiles base directory contains a component beginning with '.' -- whether the filename itself (.profile.yaml) or an intermediate directory (.hidden/profile.yaml) -- is skipped after the glob.

EnvironmentLoader::Zip passes load_dotfiles: true so that its existing behaviour (loading dotfiles from zip archives) is preserved and callers who depend on it are not silently broken.

Closes #52

silug and others added 2 commits April 21, 2026 15:44
When loading via Dir.glob on a real filesystem, Ruby's glob engine
skips hidden files and directories (those starting with '.') because
the default '*' pattern does not match dot-prefixed names.  The zip
filesystem adapter (rubyzip's Zip::FileSystem) does not share this
behaviour and could return dotfiles from its glob, leading to
inconsistent results depending on how the environment was loaded.

Add a `load_dotfiles:` keyword argument (default: false) to
ModuleLoader and thread it through EnvironmentLoader.  When false,
any file whose path relative to the compliance_profiles base directory
contains a component beginning with '.' -- whether the filename itself
(.profile.yaml) or an intermediate directory (.hidden/profile.yaml) --
is skipped after the glob.

EnvironmentLoader::Zip passes load_dotfiles: true so that its existing
behaviour (loading dotfiles from zip archives) is preserved and callers
who depend on it are not silently broken.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Rather than hard-coding load_dotfiles: true in the super() call, accept
it as a keyword argument so callers can opt out of dotfile loading when
reading from a zip archive.  The default remains true to preserve the
existing zip-loader behaviour.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add expectations to environment_loader_spec and zip_spec confirming
that load_dotfiles is passed correctly to ModuleLoader in each case:

- EnvironmentLoader defaults to load_dotfiles: false and forwards true
  when explicitly requested.
- EnvironmentLoader::Zip defaults to load_dotfiles: true (preserving
  historical zip behaviour) and forwards false when requested.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses inconsistent dotfile handling between filesystem-based and zip-based environment loading by introducing an explicit load_dotfiles: option and enforcing consistent filtering semantics.

Changes:

  • Add load_dotfiles: keyword argument (default false) to ComplianceEngine::ModuleLoader and thread it through ComplianceEngine::EnvironmentLoader.
  • Implement dotfile (and dot-directory) filtering in ModuleLoader when load_dotfiles: false.
  • Default EnvironmentLoader::Zip to load_dotfiles: true to preserve historical zip behavior, with specs covering both defaults and overrides.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
lib/compliance_engine/module_loader.rb Adds load_dotfiles: option and filters out dotfile/dot-directory paths when disabled.
lib/compliance_engine/environment_loader.rb Threads load_dotfiles: through to each ModuleLoader instance (default off).
lib/compliance_engine/environment_loader/zip.rb Defaults zip loader to load_dotfiles: true and passes it to EnvironmentLoader.
spec/classes/compliance_engine/module_loader_spec.rb Adds tests validating default exclusion and opt-in inclusion of dotfiles.
spec/classes/compliance_engine/environment_loader_spec.rb Verifies EnvironmentLoader passes load_dotfiles: through to ModuleLoader.
spec/classes/compliance_engine/environment_loader/zip_spec.rb Verifies zip loader default (true) and override behavior for load_dotfiles:.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

Inconsistent behavior with dot files

3 participants