Skip to content

feat(search): file-attribute columns and filters — Size / Modified / Created columns and size: / modified: / created: operators - #235

Merged
falbany merged 20 commits into
mainfrom
feat/227-attribute-columns
Nov 25, 2026
Merged

falbany merged 20 commits into
mainfrom
feat/227-attribute-columns

Conversation

@falbany

@falbany falbany commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Closes #227

What does this PR do?

Implements file-attribute columns and field operators so "the dumps over 100 MB from this week" becomes a typeable query:

  • Built-in column keywords resolved from stat instead of filename regex: size (human-readable, binary 1024, e.g. 12.4 MB), size_bytes (raw), modified / created (strftime via the column's transform, default %Y-%m-%d %H:%M:%S), plus string-derived path (containing directory, . at root).
  • Search operators in the existing Google-style grammar, composable with AND / OR / - / +: size:>10mb, size:1kb..1mb, size:1048576, modified:>2026-11-01, modified:<7d (recent), modified:>30d (older), modified:today, created: mirrors modified: on birthtime. Durations use the GNU-find age reading (<7d = within the last 7 days; >7d = older) per discussion on the issue. Quoted phrases stay literal; unparseable values (size:abc) fall back to plain substring — filenames containing size: are unaffected.
  • Zero-cost plain path (the issue's binding constraint): attribute columns/operators are opt-in per scan; plain scans issue zero stat calls (unit-pinned via a counting wrapper on collect_file_attrs, the only added stat path) and pass the A/B perf gate below.
  • Typed sort: attribute columns sort by bytes/epoch (900 KB before 10 MB); rows lacking attrs sort last in both directions.
  • Shared JSON fixture (searchOperators.fixture.json, 70 cases) consumed by BOTH pytest and vitest so the Python and TypeScript grammars cannot drift; parity verified under two timezones.
  • Starter template now ships File / Path / FileName / Size / Modified (Type + Version leave the defaults; keywords remain documented). Note: template-generated configs stat per row by default (worker pool) — deleting the two columns restores a zero-stat scan.
  • Web: attribute section on the filter-field tooltip only (the extension field stays extension-only — attribute operators are inert there, pinned by test), updated placeholder, created: rows, and 7 command-palette presets (larger than 100 MB / smaller than 1 MB / modified today / last 7 days / more than 30 days ago / created today / created last week) that append to the current filter as implicit AND.
  • Docs: columns guide EN/FR, column library, configuration reference — grammar, GNU-find reading, Linux created caveat, stat-cost notes.

Type of change

  • ✨ New feature (non-breaking change that adds functionality)
  • 📝 Documentation

Performance gate (issue's hard requirement)

A/B on this repository (ext=All, filter="", recursive, 3 runs per side, same interpreter, baseline from a worktree of the merge base 74be00c):

Side Median rate
Baseline (main) 28,921.80 files/s
This branch 27,939.25 files/s
Delta −3.40% — within the ±10% gate; errors=0 on all runs

Opt-in costs measured (documented, not gated): operator query +52.7% duration (sequential collection-loop stat — inherent to filtering by size/mtime); template-default columns 17,432 files/s (worker-pool stat).

Testing

  • Python: 1,849 passed (was 1,650), coverage 89.39% (>85 gate); new suites cover the grammar (unit + 70-case shared fixture), stat placement (one-stat-per-candidate, zero-stat gate, deleted-mid-scan), typed sort (10 MB/900 KB discriminator, attrs-last both directions), template defaults, extension-field inertness.
  • Web: 584 passed (42 files), tsc --noEmit clean; fixture parity suite + tooltip/placeholder + palette preset tests.
  • Quality gates: ruff format/check clean, pylint 9.88–10.00 (>8.0), pyright clean (pre-existing macOS pyobjc noise exempt per feat(web): live scan progress via the existing /api/scan/events SSE endpoint (#152) #234 precedent).
  • 18 commits; every task implemented and reviewed by independent subagents plus a final whole-branch review (APPROVE-FOR-MERGE, no Critical/Important findings).

Design decisions worth review

  • Duration reading: modified:<7d = recent, >7d = older (GNU-find), per issue discussion — the issue body's parenthetical said the opposite; a follow-up comment on feat(search): file-attribute columns and filters — built-in Size / Modified columns and size: / modified: operators #227 will correct the spec text.
  • path keyword = containing directory ("." at root), not the display path verbatim — the starter template's existing Path column already means parent directory and the File column already shows the full path; the template's Path column now uses the keyword.
  • created on Linux falls back to inode-change time (st_ctime) — documented in code, tooltip, and docs.
  • Absolute dates resolve to local midnight; today = local day of evaluation; clocks are read at match time (injectable now parameter — the shared fixture pins now per case, no wall-clock dependence in tests).
  • TS public routing: attrs == null keeps operator-shaped tokens as plain substrings (2-arg parity with match_filter).

Post-merge follow-ups (from final review, non-blocking)

  1. Object.hasOwn for the TS ATTR_FIELD lookup (adversarial constructor:-shaped queries).
  2. Unicode-digit parity (\p{Nd}+u in TS or re.ASCII in Python) — pins a normative grammar choice.
  3. size_bytes: fixture case + OR-of-two-operators case.
  4. Spec-text amendments (tooltip mechanism; path semantics) + tests-tree sync commit + one stale AGENTS.md line.

🤖 Generated with ZCode

@falbany falbany added this to the v1.0.0 milestone Nov 25, 2026
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.

feat(search): file-attribute columns and filters — built-in Size / Modified columns and size: / modified: operators

1 participant