fix(api-validation): dot-gated extension extraction so .bash_history sorts as empty - #73
Merged
Merged
Conversation
…sorts as empty
Bug:
T62 `--sort extension asc` fails on Windows live MFT with
"Not asc: bash_history > 2008" because `scripts/windows/api-validation.rs`
computes the per-row Extension column with a naive
`name.rsplit('.').next()`. For `.bash_history` (leading-dot hidden
file) that yields `"bash_history"` instead of `""`, mis-ordering it
ahead of the digit-prefixed names.
Why CLI + MCP already work, but API didn't:
v0.5.74 fixed the MCP lane (`crates/uffs-mcp/src/tools/search.rs`)
and v0.5.75 (PR #71) shipped alongside, but the same dot-gated fix
for `extension_from_name` in `uffs-format`/`uffs-core` is what the
CLI uses. The pure-RPC validation lane in `api-validation.rs` derives
its own Extension column from the daemon's `name` JSON field via
`rpc_field_computed("_ext")` and never picked up the fix.
Fix:
Add `extract_ext_dot_gated` helper mirroring
`extract_extension_after_dot` in
`crates/uffs-core/src/search/filters/ext_match.rs`. Returns empty
string for: dotless names, leading-dot hidden files, trailing-dot
names. Use it in (a) `_ext` computed column (sort + display) and
(b) the `type_*` allowlist validator (so dotless rows are not
classified by their full name as a phantom extension).
Verification:
- `rust-script -p` + `cargo check` on generated package: clean.
- Existing dot-gated regression tests in `uffs-format` /
`uffs-core` / `uffs-mcp` already pin equivalent semantics for
the workspace lanes.
Affects: T62 (sort extension asc) + type_code/document/executable/picture/system.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
T62
--sort extension ascfails on Windows live MFT with:CLI lane (
uffs.exe "*.*" --sort extension --limit 10) returns the correct order —.bash_historyfirst with empty Extension"", then digit-prefixed"2008","BIN","bin","csv","dat". MCP lane is also green (fixed in #69 / v0.5.74). Only the pure-RPC API validation lane fails.Root cause
scripts/windows/api-validation.rsderives theExtensioncolumn locally from the daemon'snameJSON field viarpc_field_computed("_ext"):".bash_history".rsplit('.').next()returns"bash_history"(post-dot suffix when the dot is at index 0), instead of the empty string the sort engine uses. Same naive extractor at line 2002 of thetype_*allowlist validator: dotless names get their full lowercased name as a phantom extension.This was the third copy of the bug. CLI/format and MCP lanes were fixed in v0.5.74 (#69) by routing through
extension_from_name/extract_extension_after_dot. The API validation lane was missed because it has its own validator-side extraction (no shared helper with the workspace).Fix
Single helper, two call sites:
Mirrors
extract_extension_after_dotincrates/uffs-core/src/search/filters/ext_match.rs. Returns""for: dotless names (README), leading-dot hidden files (.bash_history), trailing-dot names (foo.).Used in:
_extcomputed column → fixes T62 sort + Extension column display in API validator.type_*allowlist (type_code,type_document,type_executable,type_picture,type_system) → no longer mis-classifies dotless rows by their full name.Verification
rust-script --package+cargo checkon the generated package: clean compile, no new warnings.lint-fast(file-size, fmt-check, lint-prod, lint-tests, lint-ci, typos, reuse): all green.lint-pre-push(incl. smoke + check-windows): all green.crates/uffs-format/src/writer.rs,crates/uffs-core/src/output/tests.rs, andcrates/uffs-mcp/src/tools/search.rs(fix(mcp): dot-gated extension extraction so .bash_history sorts as empty #69).Out of scope
scripts/windows/api-validation.rsis arust-script(not a workspace crate), so it is not gated byjust lint-ci. Pre-existing clippy nits in unrelated parts of the file (unnecessary_filter_map,unnecessary_map_or, etc., lines 2689 / 2862 / …) are left untouched.Affects
--sort extension asc(the originally reported failure)type_code/type_document/type_executable/type_picture/type_systemvalidatorsCloses the third copy of the dot-gated extension bug; CLI / MCP / API lanes now share semantics.