Skip to content

Conversation

@cxxxr
Copy link
Member

@cxxxr cxxxr commented Dec 17, 2025

This adds glob pattern matching to *file-conversion-map* for flexible path conversion, particularly useful for Nix store paths where hash prefixes vary.

Changes

  • Add glob pattern syntax support (* for single segment, ** for recursive)
  • Add expand-path function for proper ~/, ./, and absolute path handling
  • Add resolve-glob-directory for resolving wildcard patterns to actual directories
  • Mark /nix/store/ paths as read-only in read-only-sources.lisp
  • Maintain backward compatibility with existing prefix-match patterns

Usage

;; Map Nix store paths to local .qlot directories
(setf lem-lisp-mode:*file-conversion-map*
      '(("/nix/store/*-source-patched/" . "./")))

;; Or with more specific patterns
(setf lem-lisp-mode:*file-conversion-map*
      '(("/nix/store/*-alexandria-*/" . "~/.qlot/dists/quicklisp/software/alexandria-*/")))

Test plan

  • Glob pattern matching works (* matches single path segment)
  • Path expansion handles ~/, ./, and absolute paths correctly
  • Backward compatibility with non-wildcard patterns maintained
  • Nix store files are marked as read-only

Add wildcard pattern matching (* and **) to *file-conversion-map*
for flexible path conversion, particularly useful for Nix store paths.

- Add glob-pattern-to-regex for converting glob patterns to regex
- Add expand-path for proper ~/, ./, and absolute path handling
- Add resolve-glob-directory for resolving wildcard patterns
- Mark /nix/store/ paths as read-only in read-only-sources
- Maintain backward compatibility with existing prefix-match patterns
@code-contractor-app
Copy link
Contributor

code-contractor-app bot commented Dec 17, 2025

❌ Code Contractor Validation: FAILED

✓ Code Contractor Validation Result
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📊 Statistics:
  Files Changed:    4
  Lines Added:      290
  Lines Deleted:    10
  Total Changed:    300
  Delete Ratio:     0.03 (3%)

Status: FAILED ❌

🤖 AI Providers:
  - codex — model: (Codex default)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📋 Validation Rules:

✅ max_files_changed
✅ max_total_changed_lines
✅ max_delete_ratio
✅ defpackage_rule
✅ file_structure_rule
✅ loop_keywords_rule
✅ trim_whitespace_rule
✅ naming_conventions_rule
✅ docstring_rule
✅ internal_symbol_rule
✅ error_handling_rule
✅ frontend_interface_rule
❌ functional_style_rule
✅ dynamic_symbol_call_rule
✅ alexandria_usage_rule
✅ macro_style_rule

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠️ Violations Found (1):

[ERROR] functional_style_rule
  AI check failed: "functional_style_rule"
  ❌ Reason:
    The diff continues to use a global special variable via `defvar`
    (`*file-conversion-map*`) as shared state between functions, and adds
    additional behavior/tests that rely on dynamically binding it instead of
    passing the map explicitly as a function argument.
📚 About Code Contractor

Declarative Code Standards That Learn and Improve

Define domain-specific validation rules in YAML.
Your contracts document team knowledge and evolve into more accurate AI enforcement.

Want this for your repo?
Install Code Contractor

Add comprehensive tests for:
- has-glob-wildcard-p detection
- glob-pattern-to-regex conversion
- match-glob-pattern matching
- expand-path for ~/, ./, and absolute paths
- convert-remote-to-local-file with backward compatibility
- convert-local-to-remote-file reverse conversion
Copy link
Contributor

Choose a reason for hiding this comment

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

Code Contractor: functional_style_rule

AI check failed: "functional_style_rule"

Reason:
The diff relies on the special global *file-conversion-map* (defined with defvar) as shared state between functions like convert-remote-to-local-file/convert-local-to-remote-file, instead of passing the map explicitly via function arguments.


  • Request fix suggestion

Copy link
Contributor

Choose a reason for hiding this comment

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

Code Contractor: macro_style_rule

AI check failed: "macro_style_rule"

Reason:
Uses backquote (...) outside of a macro; validation rule requires preferring list over backquote outside macros.


  • Request fix suggestion

Default mapping: /nix/store/*-source-patched/ -> ./

This enables automatic source location conversion for Nix-built
Lem without requiring user configuration.
Copy link
Contributor

Choose a reason for hiding this comment

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

Code Contractor: docstring_rule

AI check failed: "docstring_rule"

Reason:
The docstrings added to important functions convert-remote-to-local-file and convert-local-to-remote-file describe what they do but do not explain why the conversion is needed, violating the rule that important functions should explain "why", not just "what".


  • Request fix suggestion

Copy link
Contributor

Choose a reason for hiding this comment

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

Code Contractor: macro_style_rule

AI check failed: "macro_style_rule"

Reason:
Uses backquote outside of a macro (e.g., (... ,(namestring test-dir) ...)), violating the rule to prefer list over backquote outside macros.


  • Request fix suggestion

- Add 'why' explanations to docstrings for convert-remote-to-local-file
  and convert-local-to-remote-file (docstring_rule)
- Replace backquote with list/cons in test file (macro_style_rule)
Copy link
Contributor

Choose a reason for hiding this comment

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

Code Contractor: functional_style_rule

AI check failed: "functional_style_rule"

Reason:
The diff continues to use a global special variable via defvar (*file-conversion-map*) as shared state between functions, and adds additional behavior/tests that rely on dynamically binding it instead of passing the map explicitly as a function argument.


  • Request fix suggestion

@cxxxr cxxxr merged commit 8135524 into main Dec 17, 2025
9 checks passed
@cxxxr cxxxr deleted the feature/glob-pattern-file-conversion branch December 17, 2025 15: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.

2 participants