Repository navigation
fix(static+history): flag/language filters for every analyzer; root-cause oracle timeout - #26
Merged
Merged
Conversation
Non-json formats of static/complexity and all of halstead/cohesion/ comments/imports/clones walked with a default path policy, silently ignoring --include-generated/--include-vendored; --languages was never consumed by static analyzers at all. On generated-code-heavy repos this made text/json report divergent totals for identical flags (observed: 2178 vs 18653 total functions on a protobuf-heavy repo). - Add StaticFilter (path policy + language globs) in cf-commands and thread it into every static walk, every format arm, multi-analyzer merges, and plot builders; language globs use basename fnmatch (filepath.Match parity) via cf-langpath - Match cobra csv semantics: --languages "" means no filter (was an unknown-language error); verified byte-identical to the Go oracle - Fix clones serialization parity: empty non-nil clone_pairs now emits [] (vs Go's null for the nil case), via Option<Vec<ClonePair> - Add 16 regression tests incl. dispatch-level tests through the real registry (mutation self-test verified they catch the shipped bug shape), plus integration tests in cf-commands/tests/flag_parity.rs - Extend compat matrix flag family (flags x formats x analyzers, --languages axes): 9 -> 63 cells full tier, 0 -> 8 smoke tier; re-bless integrity baseline, refresh result artifacts - Record the known gap in allowlist (tracked_known_failing): the history phase ignores --languages (Go TreeDiffAnalyzer.checkLanguage not yet ported); entry stays RED in the gate Verified against the live Go oracle: 303 fixture-cell sweep clean, smoke flag family 8/8 PASS, tamper-evidence GREEN. Co-Authored-By: Claude <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
…oot-cause oracle timeout
Port the Go history-phase --languages filter (TreeDiffAnalyzer.checkLanguage)
to Rust as HistoryFilter, threaded through every history change-filter site
(devs, burndown, anomaly, couples, shotness, file-history, imports, typos,
quality, sentiment). Oracle-verified byte-identical for devs/burndown/anomaly/
couples across language flagsets.
HistoryFilter encodes two Go-history quirks measured against the live oracle:
* The history phase IGNORES --include-vendored/--include-generated (the flag
channel never reaches the history pipeline; verified on hercules +
kubernetes: byte-stable across flag/no-flag). policy is always Options::default().
* --languages "" (empty value) restricts everything away (total_commits=0),
distinct from --languages "all" / absent (no filter). Empty set != no filter.
Also fixes a latent burndown findLastTick parity bug exposed by language
filtering: last_tick is now the max delta-recorded GlobalHistory key (Go
findLastTick), not the max walked commit tick.
Root-cause the 6 --include-vendored@hercules static oracle-timeout cells:
(1) The frozen-oracle timeout is a Go BUG (pkg/uast/parser_dsl.go
toCanonicalNode re-walks every unmapped subtree twice, 2^depth blowup).
A perf-only, output-byte-identical Go patch (the same restructure Rust
landed in cf-uast/src/lowering.rs) makes the oracle complete the cell —
committed as oracle/patches/uast-unmapped-subtree-rewalk-perf.patch.
(2) The residual divergence is REAL and DELIBERATE: Rust's 64MiB durability
cap skips vendor/.../bindata.go (70.5MB; Go has no cap) = 21473 vs 21494
total functions. Cells stay RED pending an oracle re-bless + a durability-
cap policy call — recorded as tracked_known_failing (label_glob covers all
6 static cells).
Fix a gate.py _match tautology (rec.get("kind", entry["kind"]) defaulted the
record's kind to the entry's own kind, letting a family+kind entry swallow every
FAIL in that family). Records carry no kind; require an explicit match so the
6 vendor cells fall through to tracked_known_failing (honest RED) instead of
being mis-counted as ALLOWED.
Add go_nondeterminism allowlist entry for flag:static/clones--languages:Go
(6 distinct live-Go output SHAs; Go MinHash/LSH map-iteration nondeterminism).
Tests: +117 cf-commands lib tests incl. 9 history_filter_tests (git2 fixture),
flag_parity integration, 163 workspace suites green. Gate honest: 6 tracked
(still RED), 0 un-allowlisted FAIL.
Co-Authored-By: Claude <noreply@anthropic.com>
5 tasks done
dmytrogajewski
pushed a commit
that referenced
this pull request
Sep 22, 2026
The aggregate-int test helper in `mod history_filter_tests` (added by f54f1bb / #26) carries two clippy findings that the advisory CI Clippy step never failed on, but that `make lint` (`clippy --all-targets -- -D warnings`) does: * clippy::useless_format -- format!(r#""aggregate":{{"#) has no placeholders, so the brace escape was both pointless and a latent trap for whoever edits the literal next; * clippy::needless_borrows_for_generic_args -- once the literal is a &str, `json.find(&agg)` borrows a value that already satisfies the Pattern bound. Both are test-only code paths; behaviour is unchanged. Verified with `make lint`, `make deadcode`, `cargo fmt --all -- --check` (all clean) and `make test` (2480 passed, 0 failed).
5 tasks done
dmytrogajewski
added a commit
that referenced
this pull request
Sep 24, 2026
#28) * fix(history): make --limit select the newest commits and --since work `--limit N` streamed the N OLDEST commits, inherited from the retired Go reference's `initStreamingIterator` (`logOpts.Reverse = true` + CollectN). Measured on the pinned reference binary: `--limit 3` on kubernetes emits `2c4b3a562ce3` (2014-06-06) -- the repository's first commits -- and the same bytes are frozen in tests/golden/run/burndown.ndjson. No user means "the ten first commits ever made" when they type `--limit 10`. A partial `--since` window was worse: the planner counted the in-window commits, then the oldest-first loading pass applied the author-time stop filter and stopped at the first too-old commit, so the run aborted with `expected N commits, got 0: EOF`, empty stdout, exit 1 -- the documented `--since 2025-01-01` path never worked. Both bounds are now taken from ONE newest-first pass (cap at `--limit`, then reverse to the chronological order the analyzers require), which deletes the planner/loader two-pass and the abort. `--since` additionally gains git revision specs (`v1.2.0`, `HEAD~100`, a SHA) and CODEFANG_NOW-aware durations by sharing cf-gitlib's single parser; the CLI's duplicate ~130-line parser is deleted, not adapted. An unresolvable spec now reports `Error: cannot resolve --since "<value>"` instead of the generic tier-8 dispatch placeholder (same rc=1, still no stdout). Commits are still delivered oldest-first, so tick, burndown line survival and identity semantics are unchanged -- only the selected window moves. This is a deliberate divergence from the retired reference: superseded `--limit`-bounded captures are annotated (not recaptured) in tests/golden/MANIFEST.json and tests/compat/matrix.toml. The `cf-gitlib` `testutil` feature its module docs already promised makes the deterministic fixture repo usable from these tests. See specs/frds/FRD-newest-commit-window.md. Tests: 10 unit (`history_window_tests`) + 7 CLI-level e2e (`bins/codefang/tests/history_window.rs`) driving the real binary over a real repo, incl. the `--head` == `--limit 1` byte-identity invariant. Written red-first against the old behavior. `make test`: 2455 passed, 0 failed. * chore(quality): add the make lint / make deadcode gates and clear their backlog AGENTS.md mandates both gates, but neither target existed -- and `cargo clippy` could not pass anyway: it failed on deny-by-default lints (clippy::approx_constant in cf-reportutil, cf-gojson and cf-goyaml; clippy::never_loop in bins/uast), so the two pre-flight PR checkboxes were untickable by construction. - Makefile: `lint` (clippy --workspace --all-targets -- -D warnings) and `deadcode` (RUSTFLAGS="-D dead_code" cargo check --workspace --all-targets). The limitation of the latter -- rustc treats any `pub` item in a library crate as reachable, so it proves "no private code is unreachable", not "no exported function is unused" -- is documented at the target instead of glossed over. - Clear the workspace clippy backlog with real simplifications where the lint is right (single_match -> if let, if_not_else, get().is_none() -> assert against None, field_reassign_with_default -> struct update syntax, redundant closure, a no-op `& 0xFF` after `as u8`, doc backticks), and documented `#[allow]`s only where the flagged literal is a captured Go reference fixture: substituting f64::consts::PI for `3.14`/`3.14159` there would change the fixture under test, not the style. bins/uast's `for filename in files` could never iterate twice (it returns on the first pass while grammar wiring is pending), so it is now an explicit first-file bail with identical sentinel strings. - cf-uast: drop the never-read `InitState.rule_index` field. The local is still used for rule resolution; the map no longer stays alive inside every parser's init state. `make lint` and `make deadcode` both exit 0. The changelog entry for this work landed with the previous commit. No behavior or output-byte change: the workspace test suite is unchanged at 2455 passed / 0 failed. * style: rustfmt the history-window tests and handler CI's `Format check` step (`cargo fmt --all -- --check`) is a hard gate, and the two files the previous commits added/extended were not rustfmt-clean. `main` was clean, so `cargo fmt --all` touched only these two files -- verified before committing. Behavior is unchanged: `cargo fmt --all -- --check` exits 0 and `make test` is still 2455 passed / 0 failed. * chore(quality): clear clippy debt introduced by #26 The aggregate-int test helper in `mod history_filter_tests` (added by f54f1bb / #26) carries two clippy findings that the advisory CI Clippy step never failed on, but that `make lint` (`clippy --all-targets -- -D warnings`) does: * clippy::useless_format -- format!(r#""aggregate":{{"#) has no placeholders, so the brace escape was both pointless and a latent trap for whoever edits the literal next; * clippy::needless_borrows_for_generic_args -- once the literal is a &str, `json.find(&agg)` borrows a value that already satisfies the Pattern bound. Both are test-only code paths; behaviour is unchanged. Verified with `make lint`, `make deadcode`, `cargo fmt --all -- --check` (all clean) and `make test` (2480 passed, 0 failed). --------- Co-authored-by: Dmitriy <dmit8815@gmail.com>
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.
Part 1 — static flags &
--languages(previously the whole PR)Problem
codefang run -a static/complexity --format json --include-generated --include-vendored ...and the identical command with--format textreported divergent totals on generated-code-heavy repos (observed: 18 653 vs 2 178 total functions). Root cause:static/complexity, and all ofstatic/halstead,static/cohesion,static/comments,static/imports,static/clones, walked withOptions::default()— silently ignoring--include-generated/--include-vendored.--languageswas never consumed by static analyzers at all.Fix
StaticFilter(path policy + language globs) incf-commands, threaded through every static walk, every format arm (json / text / yaml / compact / bin), multi-analyzer merges, and plot builders. Language globs use basename fnmatch (filepath.Matchparity) viacf-langpath.--languages ""means "no filter" (previously an unknown-language error) — verified byte-identical to the Go oracle.clone_pairsnow emits[](Go'snullis reserved for the nil case) — fixed viaOption<Vec<ClonePair>>incf-clones; all 8 previously divergent oracle cells now PASS.Part 2 — history phase
--languages+ oracle-timeout root-cause (folded into this MR)History
--languagesfilter ported (FIXED, oracle-verified)Ports Go's
TreeDiffAnalyzer.checkLanguageto Rust asHistoryFilter, threaded through every history change-filter site (devs, burndown, anomaly, couples, shotness, file-history, imports, typos, quality, sentiment). Oracle-verified byte-identical for devs/burndown/anomaly/couples across language flagsets.flag:history/devs--languages:Go@herculesnow PASSES.HistoryFilterencodes two Go-history quirks measured against the live oracle:--include-vendored/--include-generated— the flag channel never reaches the history pipeline (verified on hercules + kubernetes: byte-stable across flag/no-flag).policyis alwaysOptions::default().--languages ""(empty value) restricts everything away (total_commits=0), distinct from--languages "all"/absent (no filter). Empty set ≠ no filter — matches Go's emptyLanguagesmap rejecting every change viacheckLanguage.Also fixes a latent burndown
findLastTickparity bug exposed by language filtering:last_tickis now the max delta-recordedGlobalHistorykey (GofindLastTick), not the max walked commit tick (this was thenum_samples 1 vs 6divergence on--languages Python).6
--include-vendored@herculesoracle-timeout cells (ROOT-CAUSED, evidence-backed; stay RED)Two layers, both diagnosed:
pkg/uast/parser_dsl.go toCanonicalNodere-walks every unmapped subtree twice (2^depth blowup). A perf-only, output-byte-identical Go patch — the same restructure Rust already landed incf-uast/src/lowering.rs— makes the oracle complete the cell with a full 5,351,785-byte report (proven byte-identical to the frozen binary on 9 diverse cells). Committed astests/compat/oracle/patches/uast-unmapped-subtree-rewalk-perf.patch.vendor/gopkg.in/vmarkovtsev/BiDiSentiment.v1/assets/bindata.go(70.5 MB; Go has no such cap and parses it) →21473vs Go's21494total functions (19 top-level funcs + 2 methods), plus tie-order diffs.These 6 cells stay RED as
tracked_known_failing(via alabel_globcovering all 6 static cells). Measuring them in-suite needs an explicit oracle re-bless (tamper_check --bless) plus a policy call on the deliberate durability caps — the explicit remaining follow-up, not something to patch around.Gate fix
gate.py _matchhad a tautology:rec.get("kind", entry["kind"])defaulted the record's kind to the entry's own kind, so afamily+kindallowlist entry matched every FAIL in that family (records carry nokind). Now requires an explicitkindmatch, so the 6 vendor cells correctly fall through totracked_known_failing(honest RED) instead of being mis-counted asALLOWED. Also added ago_nondeterminismallowlist entry forflag:static/clones--languages:Go(6 distinct live-Go output SHAs; Go MinHash/LSH map-iteration nondeterminism).Verification (both parts)
history_filter_tests(git2 fixture) and integration tests incrates/cf-commands/tests/flag_parity.rs. 163 workspace suites green.TRACKED_KNOWN_FAILING: 6(vendor cells stay RED),FAIL (un-allow): 0,ALLOWED: 0.cargo fmt --check✅ ·cargo clippyexit 0 ✅ ·cargo test --workspace✅ (163 suites) · tamper-evidence gate GREEN ✅ ·gate.py --tier fullhonest tally ✅.Remaining follow-up (not in this MR)
tamper_check --bless) to swap in the patched oracle (SHA is fingerprinted) + a durability-cap policy call on the 64 MiB cap — so the 6 vendor cells become economically measurable in-suite.🤖 Generated with Claude Code