refactor: pre-create evaluator submodules for v0.2.0 features#142
Conversation
Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io>
Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io>
Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io>
Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io>
Pre-create evaluator submodule directories for upcoming v0.2.0 features.
Split offset.rs into offset/{mod,absolute,indirect,relative}.rs and
operators.rs into operators/{mod,equality,comparison,bitwise}.rs.
Update AGENTS.md module structure documentation to match.
Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io>
Ran dist init to update cargo-dist version, regenerating release.yml and dist-workspace.toml formatting. Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io>
Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io>
…for-v020-features
|
Caution Review failedPull request was closed or merged during review Summary by CodeRabbit
WalkthroughReorganizes evaluator into offset and operator submodules with dispatchers and stubs; adds CLI completion, buffered writer I/O, and Ctrl‑C interruption handling; introduces local hooks blocking unsigned commits/tags and edits to the generated release workflow; bumps cargo-dist to v0.31.0, updates tool pins, and wide documentation/test updates. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant User as "User (CLI)"
participant Main as "src/main.rs\nCLI entry"
participant Runner as "run_analysis"
participant Processor as "process_file"
participant DB as "MagicDatabase"
participant Writer as "BufWriter"
participant Interrupt as "Ctrl‑C (AtomicBool)"
rect rgba(200,220,255,0.5)
User->>Main: invoke CLI (args, --generate-completion?)
Main->>Main: emit completion & exit (if requested)
end
rect rgba(220,255,200,0.5)
Main->>Runner: start run_analysis(args, interrupted)
Runner->>Processor: for each input -> process_file(writer,...)
Processor->>DB: evaluate rules / query database
DB-->>Processor: EvaluationResult
Processor->>Writer: write output (text/json)
Writer-->>User: flush output
end
rect rgba(255,220,200,0.5)
Interrupt->>Runner: set interrupted flag (Ctrl‑C)
Runner->>Processor: observe interrupted -> stop, flush writer, return early
Main->>User: exit with code 130
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 markdownlint-cli2 (0.21.0).claude/hookify.block-unsigned-commits.local.mdmarkdownlint-cli2 v0.21.0 (markdownlint v0.40.0) AGENTS.mdmarkdownlint-cli2 v0.21.0 (markdownlint v0.40.0) docs/README.mdmarkdownlint-cli2 v0.21.0 (markdownlint v0.40.0)
Comment |
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 CI must passWonderful, this rule succeeded.All CI checks must pass. Release-plz PRs are exempt because they only bump versions and changelogs (code was already tested on main), and GITHUB_TOKEN-triggered force-pushes suppress CI.
🟢 Do not merge outdated PRsWonderful, this rule succeeded.Make sure PRs are within 10 commits of the base branch before merging
|
Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Related Documentation 4 document(s) may need updating based on files changed in this PR: libMagic-rs architecture
|
There was a problem hiding this comment.
Pull request overview
This PR refactors the evaluator module by splitting monolithic files (operators.rs and the offset logic within absolute.rs) into focused submodules, preparing the codebase for v0.2.0 features like indirect/relative offset support. It also updates dependencies, the release workflow, adds local hookify enforcement files, and updates AGENTS.md to reflect the new structure.
Changes:
- Split
operators.rsintooperators/mod.rs(dispatcher),operators/equality.rs,operators/comparison.rs, andoperators/bitwise.rs; split offset logic intooffset/mod.rs(dispatcher),offset/absolute.rs,offset/indirect.rs(stub), andoffset/relative.rs(stub). - Updated tool and dependency versions across
mise.toml,mise.lock,dist-workspace.toml, andrelease.yml(cargo-dist 0.31.0, Rust 1.93.1, Python 3.14.3, etc.). - Added four local hookify enforcement files to block unsigned commits/tags, manual release workflow edits, and warn about emoji in PRs.
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/evaluator/operators/mod.rs |
New dispatcher: re-exports submodule functions, hosts apply_operator and integration tests |
src/evaluator/operators/equality.rs |
Moved apply_equal/apply_not_equal and their tests |
src/evaluator/operators/comparison.rs |
Moved compare_values and comparison operators with tests |
src/evaluator/operators/bitwise.rs |
Moved apply_bitwise_and, new apply_bitwise_and_mask function, and tests |
src/evaluator/operators.rs |
Deleted monolithic file (all content moved to submodules) |
src/evaluator/offset/mod.rs |
New dispatcher: resolve_offset and integration tests |
src/evaluator/offset/absolute.rs |
Trimmed to only absolute offset logic and its tests |
src/evaluator/offset/indirect.rs |
New stub for indirect offset resolution |
src/evaluator/offset/relative.rs |
New stub for relative offset resolution |
AGENTS.md |
Updated evaluator directory tree to reflect new submodule structure |
mise.toml / mise.lock |
Bumped tool/dependency versions |
dist-workspace.toml |
Updated cargo-dist to 0.31.0, minor formatting changes |
.github/workflows/release.yml |
Updated cargo-dist installer URL to v0.31.0 |
.claude/hookify.*.local.md |
Four new local enforcement hook files |
Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io>
Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io>
Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io>
- Extract map_offset_error helper to deduplicate error mapping in resolve_offset for Absolute and FromEnd arms - Pin dtolnay/rust-toolchain to commit hash instead of unpinned master ref - Fix docs incorrectly stating --use-builtin takes precedence over --magic-file; they are now mutually exclusive (conflicts_with) - Exclude .claude/ directory from mdformat pre-commit hook Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io>
…hain The quality job used dtolnay/rust-toolchain to install stable with rustfmt and clippy, but mise-action then overrode it by setting RUSTUP_TOOLCHAIN to the pinned version (1.93.1). On cache miss, mise installs the toolchain without rustfmt, causing cargo-fmt to fail. Remove the redundant action and add an explicit rustup component add step after mise to guarantee components are present. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io>
…tion Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io>
Include -j, -m, -b, -s, -t short flags alongside their long-form equivalents in all CLI documentation tables. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io>
Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io>
## 🤖 New release * `libmagic-rs`: 0.3.1 -> 0.3.2 (✓ API compatible changes) <details><summary><i><b>Changelog</b></i></summary><p> <blockquote> ## [0.3.2] - 2026-03-05 ### Refactor - Pre-create evaluator submodules for v0.2.0 features ([#142](#142)) <!-- generated by git-cliff --> </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/release-plz/release-plz/). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Summary
This PR includes infrastructure improvements, evaluator module refactoring, and CLI UX enhancements for the v0.2.0 milestone.
Evaluator Module Refactor
offset.rsinto submodules:absolute.rs,indirect.rs,relative.rsoperators.rsinto submodules:equality.rs,comparison.rs,bitwise.rsAGENTS.mdto reflect new module structureCLI UX Improvements (
rmagic)-j(json),-m(magic-file),-s(strict),-b(use-builtin),-t(timeout-ms)ArgGroupfor--json/--textmutual exclusion--use-builtinnow conflicts with--magic-file(previously use-builtin silently won)--timeout-msusesvalue_parserrange validation (1-300000) for parse-time feedback--generate-completion <SHELL>flag for shell completion generation (bash, zsh, fish, etc.)ctrlccrate (exit code 130, "Interrupted" message)BufWriter<StdoutLock>(single flush instead of per-file)after_helpso they appear after Options in--helpoutputstrip = trueadded to release and dist profilesToolchain & MSRV
rust-toolchain.tomland CI workflow to usestablechannelcollapsible_if(let-chains),manual_is_multiple_ofDependency & Tooling Updates
clap_completeandctrlcdependenciesmise.tomlanddist-workspace.tomlpipxandbuntomise.tomlWorkflow Enforcement
hookifyrules to block manual edits to release.yml, unsigned commits/tags, and emoji in PRsTests
--use-builtin/--magic-fileconflict behaviorTest plan
just ci-checkpasses locallycargo nextest run-- 982 tests passcargo clippy --all-targets -- -D warnings-- zero warningscargo fmt -- --check-- cleanrmagic --help,rmagic --version,rmagic --generate-completion bash🤖 Generated with Claude Code