fdu 0.2.0__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. {fdu-0.2.0 → fdu-0.2.1}/Cargo.lock +3 -3
  2. {fdu-0.2.0 → fdu-0.2.1}/Cargo.toml +2 -2
  3. {fdu-0.2.0 → fdu-0.2.1}/PKG-INFO +1 -1
  4. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu/Cargo.toml +1 -1
  5. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu/README.md +1 -1
  6. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu/src/cli.rs +84 -9
  7. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu/src/skills/SKILL.md +10 -7
  8. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/Cargo.toml +1 -1
  9. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/admission.rs +7 -2
  10. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/control/gitignore.rs +222 -22
  11. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/control.rs +236 -4
  12. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/execution.rs +687 -41
  13. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/index.rs +86 -40
  14. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/opened.rs +47 -0
  15. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/query/query_report.rs +42 -23
  16. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/report_format/report_epilogue.rs +49 -8
  17. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/report_format.rs +117 -19
  18. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/scan.rs +1537 -189
  19. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/snapshot.rs +73 -3
  20. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/stored_state.rs +16 -3
  21. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/test_support.rs +54 -0
  22. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/watch.rs +109 -12
  23. fdu-0.2.1/crates/fdu-core/tests/golden/opened-root/coherent-projections-and-continuations.golden +43 -0
  24. fdu-0.2.1/crates/fdu-core/tests/golden/opened-root/cold-progressive-knowledge.golden +25 -0
  25. fdu-0.2.1/crates/fdu-core/tests/golden/opened-root/exact-mutation-and-refresh.golden +45 -0
  26. fdu-0.2.1/crates/fdu-core/tests/golden/opened-root/failed-listing-and-recovery.golden +19 -0
  27. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/tests/golden/opened-root/journal-and-observation-recovery.golden +11 -11
  28. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/tests/golden/opened-root/ownership-races-and-shutdown.golden +1 -1
  29. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-py/Cargo.toml +1 -1
  30. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-py/src/lib.rs +9 -4
  31. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-py/src/opened_binding.rs +1 -0
  32. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-py/tests/public_smoke.py +19 -3
  33. {fdu-0.2.0 → fdu-0.2.1}/python/fdu/_api.py +16 -3
  34. {fdu-0.2.0 → fdu-0.2.1}/python/fdu/_models.py +8 -0
  35. {fdu-0.2.0 → fdu-0.2.1}/python/fdu/_native.pyi +1 -0
  36. {fdu-0.2.0 → fdu-0.2.1}/python/fdu/opened.py +3 -0
  37. fdu-0.2.0/crates/fdu-core/tests/golden/opened-root/coherent-projections-and-continuations.golden +0 -43
  38. fdu-0.2.0/crates/fdu-core/tests/golden/opened-root/cold-progressive-knowledge.golden +0 -25
  39. fdu-0.2.0/crates/fdu-core/tests/golden/opened-root/exact-mutation-and-refresh.golden +0 -45
  40. fdu-0.2.0/crates/fdu-core/tests/golden/opened-root/failed-listing-and-recovery.golden +0 -19
  41. {fdu-0.2.0 → fdu-0.2.1}/LICENSE +0 -0
  42. {fdu-0.2.0 → fdu-0.2.1}/README.md +0 -0
  43. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu/LICENSE +0 -0
  44. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu/build.rs +0 -0
  45. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu/src/interrupt.rs +0 -0
  46. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu/src/lib.rs +0 -0
  47. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu/src/main.rs +0 -0
  48. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu/src/progress_line.rs +0 -0
  49. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu/src/progress_ticker.rs +0 -0
  50. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu/src/skill_install.rs +0 -0
  51. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu/tests/cli_color.rs +0 -0
  52. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu/tests/cli_exit.rs +0 -0
  53. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu/tests/detached_performance_invariants.rs +0 -0
  54. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu/tests/directory_queries.rs +0 -0
  55. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu/tests/scan_watermark_integration.rs +0 -0
  56. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu/tests/watch_controls.rs +0 -0
  57. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu/tests/watch_persistence.rs +0 -0
  58. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/LICENSE +0 -0
  59. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/README.md +0 -0
  60. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/build.rs +0 -0
  61. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/rules/file-types.toml +0 -0
  62. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/cache.rs +0 -0
  63. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/classify/file_rollup_manifest.rs +0 -0
  64. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/classify/file_type_detection.rs +0 -0
  65. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/classify/manifest_toml.rs +0 -0
  66. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/classify/type_rule_manifest.rs +0 -0
  67. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/classify.rs +0 -0
  68. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/content/content_analysis.rs +0 -0
  69. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/content/content_basic_metrics.rs +0 -0
  70. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/content/content_cache.rs +0 -0
  71. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/content/content_code_metrics.rs +0 -0
  72. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/content/content_index.rs +0 -0
  73. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/content/content_markdown_metrics.rs +0 -0
  74. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/content/content_model.rs +0 -0
  75. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/content.rs +0 -0
  76. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/counters/alloc.rs +0 -0
  77. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/counters/process.rs +0 -0
  78. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/counters.rs +0 -0
  79. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/emit/emit_json.rs +0 -0
  80. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/emit/emit_scalar.rs +0 -0
  81. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/emit/emit_yaml.rs +0 -0
  82. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/emit.rs +0 -0
  83. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/engine_contract.rs +0 -0
  84. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/lib.rs +0 -0
  85. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/opened/continuation.rs +0 -0
  86. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/opened/golden_support.rs +0 -0
  87. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/opened/golden_tests.rs +0 -0
  88. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/opened/journal.rs +0 -0
  89. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/opened/read.rs +0 -0
  90. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/platform_tuning.rs +0 -0
  91. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/progress.rs +0 -0
  92. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/query/query_glob.rs +0 -0
  93. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/query/query_request.rs +0 -0
  94. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/query/query_selection.rs +0 -0
  95. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/query/query_status.rs +0 -0
  96. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/query/query_subtrees.rs +0 -0
  97. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/query/query_values.rs +0 -0
  98. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/query.rs +0 -0
  99. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/scan/macos_bulk.rs +0 -0
  100. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/scan/windows_metadata.rs +0 -0
  101. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/testdata/tree-schema-v2.json +0 -0
  102. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/testdata/yaml-scalar-corpus.json +0 -0
  103. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/testdata/yaml-scalar-corpus.yaml +0 -0
  104. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/watch/scripted_events.rs +0 -0
  105. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/src/watch_session.rs +0 -0
  106. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/tests/golden/partial-tree.txt +0 -0
  107. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/tests/golden/remainder-tree.txt +0 -0
  108. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/tests/golden/tree-populations.txt +0 -0
  109. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/tests/parallel_equivalence.rs +0 -0
  110. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/tests/partial_directory_queries.rs +0 -0
  111. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/tests/query_allocations.rs +0 -0
  112. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/tests/reference_model.rs +0 -0
  113. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/tests/state_transition_regressions.rs +0 -0
  114. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-core/tests/watch_session_integration.rs +0 -0
  115. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-py/LICENSE +0 -0
  116. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-py/README.md +0 -0
  117. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-py/examples/rollup_adapter.py +0 -0
  118. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-py/tests/run_concurrency.py +0 -0
  119. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-py/tests/smoke.py +0 -0
  120. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-py/tests/test_directory_queries.py +0 -0
  121. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-py/tests/test_models.py +0 -0
  122. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-py/tests/test_readme_examples.py +0 -0
  123. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-py/tests/test_startup.py +0 -0
  124. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-py/tests/typecheck/consumer.py +0 -0
  125. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-py/tests/typecheck/pyrightconfig.json +0 -0
  126. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-py/uv.lock +0 -0
  127. {fdu-0.2.0 → fdu-0.2.1}/crates/fdu-py/uv.toml +0 -0
  128. {fdu-0.2.0 → fdu-0.2.1}/pyproject.toml +0 -0
  129. {fdu-0.2.0 → fdu-0.2.1}/python/fdu/__init__.py +0 -0
  130. {fdu-0.2.0 → fdu-0.2.1}/python/fdu/py.typed +0 -0
@@ -173,7 +173,7 @@ checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"
173
173
 
174
174
  [[package]]
175
175
  name = "fdu"
176
- version = "0.2.0"
176
+ version = "0.2.1"
177
177
  dependencies = [
178
178
  "anstyle-query",
179
179
  "anyhow",
@@ -187,7 +187,7 @@ dependencies = [
187
187
 
188
188
  [[package]]
189
189
  name = "fdu-core"
190
- version = "0.2.0"
190
+ version = "0.2.1"
191
191
  dependencies = [
192
192
  "anstyle",
193
193
  "libc",
@@ -200,7 +200,7 @@ dependencies = [
200
200
 
201
201
  [[package]]
202
202
  name = "fdu-py"
203
- version = "0.2.0"
203
+ version = "0.2.1"
204
204
  dependencies = [
205
205
  "fdu",
206
206
  "fdu-core",
@@ -10,8 +10,8 @@ repository = "https://github.com/jlevy/fdu"
10
10
  authors = ["fdu contributors"]
11
11
 
12
12
  [workspace.dependencies]
13
- fdu-core = { version = "0.2.0", path = "crates/fdu-core", default-features = false }
14
- fdu = { version = "0.2.0", path = "crates/fdu", default-features = false }
13
+ fdu-core = { version = "0.2.1", path = "crates/fdu-core", default-features = false }
14
+ fdu = { version = "0.2.1", path = "crates/fdu", default-features = false }
15
15
 
16
16
  [workspace.lints.clippy]
17
17
  pedantic = { level = "deny", priority = -1 }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fdu
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Classifier: Development Status :: 3 - Alpha
5
5
  Classifier: Environment :: Console
6
6
  Classifier: Operating System :: MacOS
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "fdu"
3
- version = "0.2.0"
3
+ version = "0.2.1"
4
4
  # clap takes `--help`'s summary from this, so it describes the tool a user runs rather
5
5
  # than this crate's role in the layout. The golden that pins the help text caught the
6
6
  # difference the moment the binary moved, which is the corpus doing its job.
@@ -95,7 +95,7 @@ The API is documented on [docs.rs](https://docs.rs/fdu), and
95
95
  analyzer, cache policy, selection, and automation contract
96
96
  - [Repository README](https://github.com/jlevy/fdu#readme): performance evidence, cost
97
97
  layers, and how the engine works
98
- - [0.2.0 release notes](https://github.com/jlevy/fdu/blob/main/docs/project/release-notes/0.2.0.md)
98
+ - [0.2.1 release notes](https://github.com/jlevy/fdu/blob/main/docs/project/release-notes/0.2.1.md)
99
99
  and [changelog](https://github.com/jlevy/fdu/blob/main/CHANGELOG.md)
100
100
  - [Security policy](https://github.com/jlevy/fdu/blob/main/SECURITY.md)
101
101
 
@@ -299,7 +299,8 @@ CACHE BEHAVIOR
299
299
 
300
300
  --stale-ok answers from the snapshot alone: it does no filesystem verification,
301
301
  requires a compatible snapshot and content sidecar for the requested analysis,
302
- and labels its answer stale. --cache=off neither reads nor writes fdu's cache.
302
+ and labels its answer stale with a warn: line on stderr that --quiet keeps.
303
+ --cache=off neither reads nor writes fdu's cache.
303
304
 
304
305
  macOS and Linux default to ~/.cache/fdu; Windows uses %LOCALAPPDATA%/fdu.
305
306
  --cache-dir overrides FDU_CACHE_DIR, then XDG_CACHE_HOME/fdu and native defaults.
@@ -315,11 +316,12 @@ IGNORE RULES
315
316
  --ignored=only discovers gitignored matches through ordinary ancestors, reading
316
317
  only gitignored bodies for analysis. Sort and --min-size follow the size shown.
317
318
  --no-gitignore reads no rules and shows no share. Only per-directory .gitignore
318
- files apply, not core.excludesFile, .git/info/exclude, or a global ignore file,
319
- and matching is case-sensitive on every platform. An unreadable .gitignore makes
320
- the result partial, like any unreadable path. A .gitignore past --gitignore-budget
321
- or --gitignore-line-limit is refused whole and named in a note: sizes stay exact,
322
- gitignored shares under that directory do not.
319
+ files apply, not core.excludesFile, .git/info/exclude, or a global ignore file.
320
+ Each is found as git opens it, so a .GITIGNORE counts on a case-insensitive
321
+ volume; matching itself is case-sensitive on every platform. An unreadable
322
+ .gitignore makes the result partial, like any unreadable path. A .gitignore past
323
+ --gitignore-budget or --gitignore-line-limit is refused whole and named in a note:
324
+ sizes stay exact, gitignored shares under that directory do not.
323
325
 
324
326
  OUTPUT AND AUTOMATION
325
327
  Every machine report uses fdu.report/10; watch changes use fdu.stream/2.
@@ -1742,9 +1744,14 @@ fn resolve_views(spec: Option<&str>, profile: AnalysisSet) -> anyhow::Result<Res
1742
1744
  Ok(ResolvedViews { selected, omitted })
1743
1745
  }
1744
1746
 
1745
- /// Output-design boundary: flush result stdout before emitting notes, operational
1746
- /// warnings, and deduplicated tips to stderr. The caller appends `perf:` last for human
1747
- /// one-shot reports. Machine stdout receives no diagnostics or terminal escapes.
1747
+ /// Output-design boundary: flush result stdout before emitting notes, warnings, and
1748
+ /// deduplicated tips to stderr. The caller appends `perf:` last for human one-shot
1749
+ /// reports. Machine stdout receives no diagnostics or terminal escapes.
1750
+ ///
1751
+ /// Warnings come from two owners: the engine's [`report_format::report_warnings`], which
1752
+ /// describe the answer itself (a `--stale-ok` answer nothing verified), then this
1753
+ /// frontend's operational ones (a failed save, each retained status issue). `--quiet`
1754
+ /// keeps every warning, on every format, and drops only notes, tips, and `perf:`.
1748
1755
  ///
1749
1756
  /// Use stderr's color decision: note/tip/perf are gray, warn is yellow without bold,
1750
1757
  /// and fatal rendering in `finish` is red bold. Preserve paths and causes on warning
@@ -1767,6 +1774,9 @@ fn write_report_diagnostics(
1767
1774
  writeln!(diagnostic, "{}", paint(&line, STYLE_PERFORMANCE, color))?;
1768
1775
  }
1769
1776
  }
1777
+ for warning in report_format::report_warnings(report) {
1778
+ writeln!(diagnostic, "{}", paint(&warning, STYLE_WARNING, color))?;
1779
+ }
1770
1780
  if let Some(warning) = save_warning {
1771
1781
  writeln!(diagnostic, "{}", paint(warning, STYLE_WARNING, color))?;
1772
1782
  }
@@ -3193,6 +3203,71 @@ mod tests {
3193
3203
  );
3194
3204
  }
3195
3205
 
3206
+ /// A `--stale-ok` answer is marked on stderr by a warning that `--quiet` keeps, on the
3207
+ /// plain text report and every other format, and a verified answer carries no such
3208
+ /// line. Before this, plain text said only `cache only` at the end of the `perf:`
3209
+ /// footer, and `--quiet` removed that too (fdu-mdop).
3210
+ #[test]
3211
+ fn quiet_keeps_the_stale_answer_warning_and_a_verified_answer_has_none() {
3212
+ const WARNING: &str = "warn: stale answer: served from the snapshot without filesystem \
3213
+ verification; drop --stale-ok for a fresh answer\n";
3214
+ let root = tempfile::tempdir().expect("tempdir");
3215
+ std::fs::write(root.path().join("one.txt"), b"one\n").expect("write");
3216
+ let cache = tempfile::tempdir().expect("cache dir");
3217
+ let command = |view: &str, format: &str, cache_policy: &str, stale_ok, quiet| Cli {
3218
+ path: Some(root.path().to_path_buf()),
3219
+ view: Some(view.to_string()),
3220
+ format: format.to_string(),
3221
+ size: "apparent".to_string(),
3222
+ cache: cache_policy.to_string(),
3223
+ cache_dir: Some(cache.path().to_path_buf()),
3224
+ stale_ok,
3225
+ quiet,
3226
+ ..cli()
3227
+ };
3228
+ let run = |command: Cli| {
3229
+ let (mut out, mut diagnostic) = (Vec::new(), Vec::new());
3230
+ command
3231
+ .run(
3232
+ &mut out,
3233
+ &mut diagnostic,
3234
+ false,
3235
+ &TerminalFacts::default(),
3236
+ ProgressIo::inert(),
3237
+ )
3238
+ .expect("report");
3239
+ (
3240
+ String::from_utf8(out).expect("UTF-8 stdout"),
3241
+ String::from_utf8(diagnostic).expect("UTF-8 stderr"),
3242
+ )
3243
+ };
3244
+
3245
+ // `on` leaves the snapshot a stale answer reads; its own answer is verified.
3246
+ let (_, seeded) = run(command("tree", "text", "on", false, false));
3247
+ assert!(!seeded.contains("warn:"), "a cold scan is not stale: {seeded}");
3248
+ let (fresh_out, fresh) = run(command("summary", "text", "auto", false, false));
3249
+ assert!(!fresh.contains("warn:"), "a verified answer is not stale: {fresh}");
3250
+ let (_, fresh_quiet) = run(command("summary", "text", "auto", false, true));
3251
+ assert!(fresh_quiet.is_empty(), "nothing to keep: {fresh_quiet:?}");
3252
+
3253
+ let (stale_out, stale) = run(command("summary", "text", "auto", true, false));
3254
+ assert_eq!(stale_out, fresh_out, "an unchanged tree gives the same answer");
3255
+ let warning = stale.find(WARNING).unwrap_or_else(|| panic!("stale marker: {stale}"));
3256
+ let perf = stale.find("perf:").expect("a text report closes with perf:");
3257
+ assert!(warning < perf, "warnings precede the performance footer: {stale}");
3258
+ assert!(stale.trim_end().ends_with("cache only"), "{stale}");
3259
+
3260
+ let (quiet_out, quiet) = run(command("summary", "text", "auto", true, true));
3261
+ assert_eq!(quiet_out, stale_out, "quiet leaves result stdout intact");
3262
+ assert_eq!(quiet, WARNING, "quiet keeps the stale marker and nothing else");
3263
+ for (view, format) in [("summary", "json"), ("list", "paths")] {
3264
+ let (_, quiet) = run(command(view, format, "auto", true, true));
3265
+ assert_eq!(quiet, WARNING, "{format} keeps the same marker under quiet");
3266
+ let (_, fresh_quiet) = run(command(view, format, "auto", false, true));
3267
+ assert!(!fresh_quiet.contains("warn:"), "{format}: {fresh_quiet}");
3268
+ }
3269
+ }
3270
+
3196
3271
  /// The footer's walked size is measured as the answer is, so it reads as the summary
3197
3272
  /// row's own total under the default and under `--size apparent` alike. (On Windows
3198
3273
  /// allocated falls back to apparent, and the two readings agree.)
@@ -150,13 +150,13 @@ bodies may be skipped.
150
150
  A retained index can answer narrower queries when it holds the required facts.
151
151
 
152
152
  Work has three layers.
153
- A single unfiltered `--no-gitignore --view summary PATH` is the one exact composition
154
- that retains only aggregate tallies and no index, except under `--cache on` and
155
- `--stale-ok`, whose contracts are about the snapshot itself.
153
+ A single unfiltered `--view summary PATH` is the one exact composition that retains only
154
+ aggregate tallies and no index, except under `--cache on` and `--stale-ok`, whose
155
+ contracts are about the snapshot itself.
156
156
  Otherwise a snapshot cannot save the walk that request is already doing, so it neither
157
157
  reads nor writes one.
158
- Without `--no-gitignore` the summary reads `.gitignore` to report its ignored share,
159
- which needs the index.
158
+ Reading `.gitignore`, the summary keeps the rules and classifies each entry as it counts
159
+ it, so its ignored share needs no index either.
160
160
  Ordinary metadata requests retain the reusable index but never read regular-file
161
161
  contents. One-shot metadata reports under `auto` neither load a snapshot, which cannot
162
162
  avoid the current metadata walk, nor write one; `--cache on` writes one.
@@ -357,7 +357,9 @@ The default `include` measures both populations and reports their contributions
357
357
  separately. Unknown classifications cannot justify pruning.
358
358
  `--no-gitignore` with either selection is a usage error.
359
359
  Only per-directory `.gitignore` files apply, not `core.excludesFile`,
360
- `.git/info/exclude`, or a global ignore file, and matching is case-sensitive.
360
+ `.git/info/exclude`, or a global ignore file.
361
+ Each is found as git opens it, so a `.GITIGNORE` counts on a case-insensitive volume;
362
+ matching itself is case-sensitive.
361
363
  Unignored does not mean tracked: `.git` is unignored unless a rule names it.
362
364
  For recent working files, add both `--ignored=exclude` and `--exclude='.git/**'`. An
363
365
  unreadable `.gitignore` makes the result partial (exit 2), while one past
@@ -418,7 +420,8 @@ Check the process exit status and these fields:
418
420
 
419
421
  `provenance.source` is `cold_scan`, `warm_revalidate`, or `cache_only`. Only
420
422
  `--stale-ok` can return `provenance.freshness: stale`, and it says so rather than
421
- implying currency; it fails outright when no usable snapshot exists rather than silently
423
+ implying currency: every format also prints a `warn: stale answer` line on stderr, which
424
+ `--quiet` keeps. It fails outright when no usable snapshot exists rather than silently
422
425
  scanning.
423
426
 
424
427
  Exit 0 is accepted success, exit 1 is a fatal failure, and exit 2 is incomplete data or
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "fdu-core"
3
- version = "0.2.0"
3
+ version = "0.2.1"
4
4
  description = "The fdu engine: incremental hierarchical tallies over large directory trees"
5
5
  readme = "README.md"
6
6
  documentation = "https://docs.rs/fdu-core"
@@ -72,13 +72,18 @@ impl HiddenPolicy {
72
72
  pub(crate) enum Disposition {
73
73
  /// Retain the ordinary row and any control signal it carries.
74
74
  Retain,
75
- /// Retain only the exact `.gitignore` signal.
75
+ /// Retain only the `.gitignore` signal: the entry spells the control name, in any
76
+ /// case, and the directory's control is read as a visible one would be.
76
77
  ControlOnly,
77
78
  /// Retain neither the row nor a control signal.
78
79
  Reject,
79
80
  }
80
81
 
81
82
  /// Decide one direct child after its native kind has been observed.
83
+ ///
84
+ /// A hidden-pruned `.GITIGNORE` stays a control signal like `.gitignore`: on a
85
+ /// case-insensitive volume it is the directory's control file, and whether it is one is
86
+ /// the control read's question, not admission's (`crate::control::ControlSpelling`).
82
87
  pub(crate) fn decide(
83
88
  name: &OsStr,
84
89
  kind: EntryKind,
@@ -86,7 +91,7 @@ pub(crate) fn decide(
86
91
  exclude_special: bool,
87
92
  ) -> Disposition {
88
93
  if !hidden.admits(name) {
89
- return if name == crate::control::CONTROL_FILE_NAME {
94
+ return if crate::control::control_spelling(name).is_some() {
90
95
  Disposition::ControlOnly
91
96
  } else {
92
97
  Disposition::Reject
@@ -29,6 +29,44 @@
29
29
 
30
30
  use std::path::{Component, Path};
31
31
 
32
+ /// Path components matched without a heap allocation. Deeper paths still match exactly;
33
+ /// they collect into a vector first.
34
+ const INLINE_COMPONENTS: usize = 32;
35
+
36
+ /// Positions a `**` pattern tracks on the stack: a path of up to this many components,
37
+ /// plus the empty prefix. Deeper paths use heap rows with the same arithmetic.
38
+ const INLINE_POSITIONS: usize = 64;
39
+
40
+ /// Call `each` with the normal components of `path`, then `last` if given, without a heap
41
+ /// allocation for a path of up to [`INLINE_COMPONENTS`] of them.
42
+ pub(super) fn with_components<R>(
43
+ path: &Path,
44
+ last: Option<&[u8]>,
45
+ each: impl FnOnce(&[&[u8]]) -> R,
46
+ ) -> R {
47
+ let mut inline: [&[u8]; INLINE_COMPONENTS] = [&[]; INLINE_COMPONENTS];
48
+ let mut spilled: Vec<&[u8]> = Vec::new();
49
+ let mut count = 0usize;
50
+ let normal = path.components().filter_map(|component| match component {
51
+ Component::Normal(value) => Some(value.as_encoded_bytes()),
52
+ Component::CurDir | Component::ParentDir | Component::RootDir | Component::Prefix(_) => {
53
+ None
54
+ }
55
+ });
56
+ for bytes in normal.chain(last) {
57
+ if count < INLINE_COMPONENTS {
58
+ inline[count] = bytes;
59
+ } else {
60
+ if spilled.is_empty() {
61
+ spilled.extend_from_slice(&inline);
62
+ }
63
+ spilled.push(bytes);
64
+ }
65
+ count += 1;
66
+ }
67
+ each(if count <= INLINE_COMPONENTS { &inline[..count] } else { &spilled[..] })
68
+ }
69
+
32
70
  #[derive(Clone, Debug, Default)]
33
71
  pub(super) struct Gitignore {
34
72
  patterns: Vec<Pattern>,
@@ -38,10 +76,21 @@ pub(super) struct Gitignore {
38
76
  struct Pattern {
39
77
  ignored: bool,
40
78
  directory_only: bool,
41
- matches_path: bool,
79
+ shape: Shape,
42
80
  segments: Vec<Segment>,
43
81
  }
44
82
 
83
+ /// What a pattern is matched against, decided once when it is parsed.
84
+ #[derive(Clone, Copy, Debug, PartialEq, Eq)]
85
+ enum Shape {
86
+ /// No `/`: one glob against the entry's own name.
87
+ Basename,
88
+ /// Anchored or holding a `/` but no `**`: only a path of the pattern's length.
89
+ Fixed,
90
+ /// Holding a `**`, which spans any number of components.
91
+ Spanning,
92
+ }
93
+
45
94
  #[derive(Clone, Debug)]
46
95
  enum Segment {
47
96
  DoubleStar,
@@ -64,21 +113,16 @@ impl Gitignore {
64
113
 
65
114
  /// Last matching line wins. `Some(false)` is an explicit negation; `None` means this
66
115
  /// control file expressed no opinion.
116
+ ///
117
+ /// Every classified entry asks this once per control file on its path, so it must not
118
+ /// allocate: the components of an ordinary path fit a stack buffer, and only a path
119
+ /// deeper than it spills to the heap (H162).
67
120
  pub(super) fn matches(&self, relative: &Path, is_dir: bool) -> Option<bool> {
68
- let components: Vec<&[u8]> = relative
69
- .components()
70
- .filter_map(|component| match component {
71
- Component::Normal(value) => Some(value.as_encoded_bytes()),
72
- Component::CurDir
73
- | Component::ParentDir
74
- | Component::RootDir
75
- | Component::Prefix(_) => None,
76
- })
77
- .collect();
78
- self.matches_components(&components, is_dir)
79
- }
80
-
81
- fn matches_components(&self, components: &[&[u8]], is_dir: bool) -> Option<bool> {
121
+ with_components(relative, None, |components| self.matches_components(components, is_dir))
122
+ }
123
+
124
+ /// [`Self::matches`] over components already split, relative to this file's directory.
125
+ pub(super) fn matches_components(&self, components: &[&[u8]], is_dir: bool) -> Option<bool> {
82
126
  self.patterns
83
127
  .iter()
84
128
  .filter(|pattern| pattern.matches(components, is_dir))
@@ -153,21 +197,34 @@ impl Pattern {
153
197
  if segments.is_empty() {
154
198
  return None;
155
199
  }
156
- Some(Self { ignored, directory_only, matches_path, segments })
200
+ let shape = if !matches_path {
201
+ Shape::Basename
202
+ } else if segments.iter().all(|segment| matches!(segment, Segment::Glob(_))) {
203
+ Shape::Fixed
204
+ } else {
205
+ Shape::Spanning
206
+ };
207
+ Some(Self { ignored, directory_only, shape, segments })
157
208
  }
158
209
 
159
210
  fn matches(&self, path: &[&[u8]], is_dir: bool) -> bool {
160
211
  if path.is_empty() {
161
212
  return false;
162
213
  }
163
- if !self.matches_path {
214
+ if self.shape == Shape::Basename {
164
215
  let Some(Segment::Glob(pattern)) = self.segments.first() else {
165
216
  return false;
166
217
  };
167
218
  return path.last().is_some_and(|component| glob_matches(pattern, component))
168
219
  && (!self.directory_only || is_dir);
169
220
  }
170
- segment_path_matches(&self.segments, path, self.directory_only, is_dir)
221
+ segment_path_matches(
222
+ &self.segments,
223
+ self.shape == Shape::Fixed,
224
+ path,
225
+ self.directory_only,
226
+ is_dir,
227
+ )
171
228
  }
172
229
  }
173
230
 
@@ -234,15 +291,48 @@ fn normalize_glob(pattern: &[u8]) -> Vec<u8> {
234
291
 
235
292
  fn segment_path_matches(
236
293
  pattern: &[Segment],
294
+ glob_only: bool,
237
295
  path: &[&[u8]],
238
296
  directory_only: bool,
239
297
  target_is_dir: bool,
240
298
  ) -> bool {
241
- let mut previous = vec![false; path.len() + 1];
299
+ if directory_only && !target_is_dir {
300
+ return false;
301
+ }
302
+ // Without a `**`, each segment consumes exactly one component, so only a path of the
303
+ // pattern's length can match, and it matches segment for segment. This is the shape
304
+ // of every anchored rule such as `/vmlinux`, which most entries fail on length alone.
305
+ if glob_only {
306
+ return pattern.len() == path.len()
307
+ && pattern.iter().zip(path).all(|(segment, component)| match segment {
308
+ Segment::Glob(glob) => glob_matches(glob, component),
309
+ Segment::DoubleStar | Segment::DoubleStarOneOrMore => false,
310
+ });
311
+ }
312
+ let positions = path.len() + 1;
313
+ if positions <= INLINE_POSITIONS {
314
+ let mut previous = [false; INLINE_POSITIONS];
315
+ let mut current = [false; INLINE_POSITIONS];
316
+ double_star_matches(pattern, path, &mut previous[..positions], &mut current[..positions])
317
+ } else {
318
+ double_star_matches(pattern, path, &mut vec![false; positions], &mut vec![false; positions])
319
+ }
320
+ }
321
+
322
+ /// The general matcher for a pattern holding `**`: `previous[i]` says the segments so
323
+ /// far can consume exactly the first `i` path components. The rows are supplied by the
324
+ /// caller so the common depth needs no allocation.
325
+ fn double_star_matches<'rows>(
326
+ pattern: &[Segment],
327
+ path: &[&[u8]],
328
+ mut previous: &'rows mut [bool],
329
+ mut current: &'rows mut [bool],
330
+ ) -> bool {
331
+ previous.fill(false);
242
332
  previous[0] = true;
243
333
 
244
334
  for (position, segment) in pattern.iter().enumerate() {
245
- let mut current = vec![false; path.len() + 1];
335
+ current.fill(false);
246
336
  match segment {
247
337
  Segment::DoubleStar if position + 1 < pattern.len() => {
248
338
  current[0] = previous[0];
@@ -265,10 +355,10 @@ fn segment_path_matches(
265
355
  }
266
356
  }
267
357
  }
268
- previous = current;
358
+ std::mem::swap(&mut previous, &mut current);
269
359
  }
270
360
 
271
- previous[path.len()] && (!directory_only || target_is_dir)
361
+ previous[path.len()]
272
362
  }
273
363
 
274
364
  fn glob_matches(pattern: &[u8], text: &[u8]) -> bool {
@@ -565,6 +655,116 @@ mod tests {
565
655
  }
566
656
  }
567
657
 
658
+ /// The matcher before H162: heap rows for every pattern and no length shortcut. Kept
659
+ /// as the oracle the allocation-free paths must agree with.
660
+ fn reference_segment_path_matches(
661
+ pattern: &[Segment],
662
+ path: &[&[u8]],
663
+ directory_only: bool,
664
+ target_is_dir: bool,
665
+ ) -> bool {
666
+ let mut previous = vec![false; path.len() + 1];
667
+ previous[0] = true;
668
+ for (position, segment) in pattern.iter().enumerate() {
669
+ let mut current = vec![false; path.len() + 1];
670
+ match segment {
671
+ Segment::DoubleStar if position + 1 < pattern.len() => {
672
+ current[0] = previous[0];
673
+ for path_at in 1..=path.len() {
674
+ current[path_at] = previous[path_at] || current[path_at - 1];
675
+ }
676
+ }
677
+ Segment::DoubleStar | Segment::DoubleStarOneOrMore => {
678
+ for path_at in 1..=path.len() {
679
+ current[path_at] = previous[path_at - 1] || current[path_at - 1];
680
+ }
681
+ }
682
+ Segment::Glob(glob) => {
683
+ for path_at in 1..=path.len() {
684
+ current[path_at] =
685
+ previous[path_at - 1] && glob_matches(glob, path[path_at - 1]);
686
+ }
687
+ }
688
+ }
689
+ previous = current;
690
+ }
691
+ previous[path.len()] && (!directory_only || target_is_dir)
692
+ }
693
+
694
+ #[test]
695
+ fn allocation_free_matching_agrees_with_the_heap_rows_at_every_depth() {
696
+ // Depths straddle both stack buffers: 32 inline components, 63 inline positions.
697
+ let sources: &[&[u8]] = &[
698
+ b"/a",
699
+ b"/a/b",
700
+ b"a/b",
701
+ b"/a/*",
702
+ b"*/b",
703
+ b"a/**",
704
+ b"**/b",
705
+ b"a/**/b",
706
+ b"/a/**/b/",
707
+ b"**/a/**",
708
+ b"a/**\\/b",
709
+ b"/[ab]/?",
710
+ b"a/b/",
711
+ b"**/**/b",
712
+ b"**\\/b",
713
+ b"a/**\\/**\\/b",
714
+ b"/**",
715
+ b"**/b/",
716
+ b"!a/**/b",
717
+ b"/\xc3\xa9/*",
718
+ ];
719
+ for &source in sources {
720
+ let pattern = Pattern::parse(source).expect("fixture pattern parses");
721
+ for depth in [1usize, 2, 3, 31, 32, 33, 62, 63, 64, 70] {
722
+ for shape in 0..5 {
723
+ let names: Vec<Vec<u8>> = (0..depth)
724
+ // All `a`; `a` ending in `b`; `a` then all `b`; a multi-byte name then
725
+ // `a`; distinct names.
726
+ .map(|at| match (shape, at) {
727
+ (1, at) if at + 1 == depth => b"b".to_vec(),
728
+ (2, at) if at > 0 => b"b".to_vec(),
729
+ (3, 0) => "\u{e9}".as_bytes().to_vec(),
730
+ (0..=3, _) => b"a".to_vec(),
731
+ _ => format!("n{at}").into_bytes(),
732
+ })
733
+ .collect();
734
+ let path: Vec<&[u8]> = names.iter().map(Vec::as_slice).collect();
735
+ let joined = names.join(&b'/');
736
+ let text = std::str::from_utf8(&joined).expect("fixture names are UTF-8");
737
+ for is_dir in [false, true] {
738
+ let expected = if pattern.shape == Shape::Basename {
739
+ pattern.matches(&path, is_dir)
740
+ } else {
741
+ reference_segment_path_matches(
742
+ &pattern.segments,
743
+ &path,
744
+ pattern.directory_only,
745
+ is_dir,
746
+ )
747
+ };
748
+ assert_eq!(
749
+ pattern.matches(&path, is_dir),
750
+ expected,
751
+ "{} against a depth-{depth} path, shape {shape}, dir {is_dir}",
752
+ String::from_utf8_lossy(source)
753
+ );
754
+ let mut line = source.to_vec();
755
+ line.push(b'\n');
756
+ assert_eq!(
757
+ Gitignore::parse(&line).matches(Path::new(text), is_dir),
758
+ expected.then_some(pattern.ignored),
759
+ "{} through the public matcher at depth {depth}",
760
+ String::from_utf8_lossy(source)
761
+ );
762
+ }
763
+ }
764
+ }
765
+ }
766
+ }
767
+
568
768
  #[test]
569
769
  fn repeated_double_star_segments_have_bounded_matching_work() {
570
770
  let mut source = b"**/".repeat(40);