Repository navigation
fix: land the ten #1768 follow-ups - #1788
Merged
Merged
Conversation
dekobon
force-pushed
the
fix/batch-2026-11-01-2
branch
from
November 3, 2026 21:03
27eff68 to
385186f
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1788 +/- ##
========================================
Coverage 98.33% 98.34%
========================================
Files 391 392 +1
Lines 116610 117002 +392
Branches 116175 116567 +392
========================================
+ Hits 114673 115069 +396
+ Misses 1219 1217 -2
+ Partials 718 716 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
dekobon
force-pushed
the
fix/batch-2026-11-01-2
branch
from
November 4, 2026 00:08
385186f to
811c968
Compare
Every test helper that spawns `git init` now runs git with `GIT_CONFIG_GLOBAL=/dev/null`, `GIT_CONFIG_NOSYSTEM=1` and a command-scope `core.excludesFile` / `core.attributesFile` pin (`GIT_CONFIG_COUNT=2`), applied after the caller's environment so no caller can switch them back on. The two config variables alone leave `$XDG_CONFIG_HOME/git/ignore` active: it is not a config file, and a host copy containing `*` made `git add .` stage nothing under the original isolation, measured on git 2.34.1. Ten helper sites lacked the isolation, not the six the issue lists: the seven CLI integration helpers move onto a new shared `tests/common/git_fixture.rs` (`run_git`, `git_at`, `try_git`, `git_output`, `HostileGitHost`); `blame_fixture` in `vcs_command.rs`, the two web closures and the three Python fixtures get it inline, since test modules do not cross crates. The root crate's `run_git` takes the same `excludesFile` pin. Each location gains a hostile-config test. On this host `git init` runs no `reference-transaction` hook (the hook reaches `init` from 2.46), so the tests discriminate on every git and platform through a `user.name` sentinel read back through the isolated helper, asserting git's exit 1 for an unset key, plus a hostile `git/ignore` that fails the first commit when the pin is missing; hooks are installed only on unix by a cfg'd item pair and the tests themselves are ungated. Verified by revert: dropping `GIT_CONFIG_COUNT` from any helper fails that helper's test on its first commit; with hooks neutralised, dropping either `GIT_CONFIG_GLOBAL` or `GIT_CONFIG_NOSYSTEM` fails the sentinel in all five legs (CLI, CLI unit, web, root, Python). Fixes #1771
`bca diff` reports a leaf numeric on one side only as an added or removed field, one row per leaf. Two captures taken with different `--metrics` sets, or by two bca versions whose emitters differ, list every leaf of every missing family, zeros included: 110 rows per file for the default set against `--metrics cyclomatic`, and the Markdown form crossed GitHub's comment cap at under ten files. The text and Markdown renderers now roll a family wholly absent on one side up to one row per file and metric bucket, `src/a.rs mi (all 3 field(s))`, with N the numeric leaves on the present side. A family present on both sides keeps its per-leaf rows, since which leaves differ is then the information; so do numeric/null and scalar/object transitions, which are not an absent family. Design: the fact is carried as a `#[serde(skip)]` trailing field on `FieldPresence`, derived in `metric_leaves` from the family key being missing on exactly one side and held in the one-sided `LeafValues` variants so a `Both` leaf cannot carry it. The collapse lives in `presence_rows`, which both human renderers share, and groups adjacent rows of the `(file, metric, field)` sort with `chunk_by`. The JSON rows, `summary.added_fields` / `removed_fields` and `--exit-code` are per leaf as before: the JSON output for the issue's pair is byte-identical (220 rows, exit 2), the Markdown drops from 14 230 to 2 514 bytes. The per-(metric, field) form with a file count, which would be independent of tree size, is not implemented. Verified by revert: clearing the flag in `metric_leaves` fails nine tests, forcing it on a partial family fails seven, dropping the `a.file == b.file` clause of the grouping fails the two-file fixture. Fixes #1766
`bca metrics --vcs` and `--vcs-per-function` scored a `hotspot_score` whatever `--metrics` selected: with `--metrics nargs` the file block multiplied churn by a subtree sum of 0 and every nested block by the default own value of 1, neither a computed complexity. The book and the Python bindings already omit the field in that case, and `vcs::Stats::hotspot_score` documents it as `Some` only when the complexity was computed, so the CLI broke its own library's contract. `set_hotspot_score` becomes `hotspot_for(stat, selected, cyclomatic)`, assigning `Some` only when `selected` carries cyclomatic, the same set the wire serializer consults to elide the `cyclomatic` block, and an explicit `None` otherwise, so a stat a `HistoryIndex::new` caller seeded cannot leak a stale score through. Both call sites keep their figure, the subtree sum at the file and the own value per function. The bindings' `attach_vcs_to_space` takes the same assignment in place of a skip, and the doc that called the omission a deliberate difference from the CLI goes. The `report --vcs` channel stays unconditional because `report` has no `--metrics`; a maintainer comment says so, and #1743 gives it the shared helper. The CLI-bindings parity test gains a `--metrics nargs` row that asserts five blocks on both sides and no `hotspot_score` key on either, so it cannot pass as two empty maps. Docs that said "when AST metrics are computed" now say "when cyclomatic is among the computed metrics", since `--metrics nargs` computes AST metrics and emits none. Verified by revert: making the gate unconditional fails the new CLI unit test and the parity row with the issue's 0.0 / 8.0 / 4.0; turning the `None` arm back into a skip fails the seeded tests on both sides. Fixes #1742
`read_file_with_eol` decided "three bytes or fewer" from `st_size` alone and opened only a regular file as its readability probe, so a directory whose `st_size` is under the gate — every directory on NTFS, an empty or nearly empty one on btrfs and ZFS — was declined as `Empty` or `TooSmall` without being opened, against the documented promise of an "is a directory" error. On ext4 and APFS a directory is 4096 or 64 bytes, took the ordinary read, and failed with EISDIR. The tiny branch now probes a directory as it probes a regular file, with one open and a one-byte read whose error propagates, so the result is the platform's own: `IsADirectory` from the first read on Unix, where `open(2)` succeeds on a directory, and `PermissionDenied` from the open on Windows, which std issues without backup semantics. A FIFO, socket or device stays unopened. `Ast::from_path` and the bindings' `analyze_path` drop the second `stat` each carried to recover the error on the decline path, and the CLI's file dispatcher counts a directory as a read failure rather than a dispatched empty file. The reader signatures are unchanged, so this is a fix within the STABILITY contract. The new reader test is platform-ungated with a cfg-split expected kind, because the branch is reached only where a directory is small: this btrfs host and CI's Windows leg, never the ext4 runners. Verified by revert here: restoring the regular-file-only probe fails that test, the `Ast::from_path` test, and both `analyze_path` tests. Fixes #1762
`VcsRepoCache::attach` looked the blame session up with `contains_key` and then `get_mut`, two hashes of the repository root per file on a hit; the comment justifying that shape said it avoided cloning the root, which has been an `Arc<Path>` since #1349, so the clone is a refcount bump. Both maps now take the one-hash `entry().or_insert_with` shape the index path already had. A failed open stays cached as `None` and is not retried per file. The per-file `canonicalize()` in `inject_vcs_with_index` stays. It was profiled first, as the issue asked: on a release build over this repository's `src/` (1 294 files) with `vcs=True`, `readlinkat` was 2 962 calls and about 0.006 s of a 0.67 s wall, under one percent; per-function blame dominates ten times over. A lexical-first lookup that canonicalized only on a miss removed those calls but attached the wrong history for a tracked path that is itself a symlink to another tracked file, since `HistoryIndex::get_for_path` strips the canonical work tree lexically and the symlink's own path is a key. That case is now a regression test: `a.py` replaced in the work tree by a link to `b.py` carries `b.py`'s two commits, not `a.py`'s one. Measured at f21ea8ed with rustc 1.99.0, maturin 1.15.0, Python 3.14.8: `strace -f -c -e trace=readlink,readlinkat,lstat,newfstatat,statx` over `analyze_paths("<repo>/src", vcs=True)`; wall time interleaved A/B, five runs, was inside host noise either way. Fixes #1764
`bca metrics --vcs-per-function` collected descendant spans and attached their blame stats with two recursive walks that run before serialization, the only stage that bounds the space depth (`MAX_SPACE_SERIALIZE_DEPTH`, 128). Input nested past what the thread stack holds therefore overflowed and aborted the process with exit 134 instead of reaching the serializer's error: a committed `deep.rs` of 10 000 nested functions aborted a consumer thread, where `--vcs` on the same file exited 1 with "deeper than the serialization limit". Both walks now use an explicit stack of child iterators, the form the Python bindings took in #1768, in the same pre-order so spans and stats stay in lockstep; the two copies are lifted into the library by the serializer's error on every flag. Two bindings comments said a serialization failure was unreachable; the depth bound makes it reachable, and the Python test `test_vcs_per_function_past_the_serialize_depth_raises` triggers it. Tests: the bindings' bounded-stack test is mirrored (10 000-deep chain on a 128 KiB thread, failing as an abort when either walk recurses), and a pre-order fixture with a shallow sibling before and after a deep subtree, each span carrying a distinct churn, fails under a post-order, breadth-first, or reversed-sibling walk — the trailing sibling is what makes the walk resume an ancestor's iterator after unwinding. Verified by revert for each walk and for a breadth-first mutant. The file's `loc.ploc` baseline moves 541 to 551 for the ten lines the explicit stacks add; #1743 removes the walks from this file. Fixes #1770
Which cyclomatic figure a `hotspot_score` is scored from — the file block's subtree sum, each nested block's own value, and `None` when cyclomatic was not computed — was written out in four places: the CLI's `bca metrics --vcs` and `--vcs-per-function` injectors, the Python bindings' injectors, and the `bca report --vcs` join. The copies drifted twice (#709 fixed one, #1624 another, #1742 a third), and the blocker that kept a shared helper out of #1624 went when #1768 moved the bindings' attach onto the typed `FuncSpace`. The new public `vcs::attach` module is the one owner: `file_complexity` (the figure the file block and `report --vcs` score from, or `None`), `attach_file_history` (canonicalize, look up, attach with the subtree sum — the canonicalize stays, see #1764) and `attach_per_function_history` (one blame, then one own-scored block per descendant in pre-order, returning the blame error for the front-end to report or ignore). The figure selector and the single gate behind both functions are crate-private, so no caller can apply the wrong figure to a space. The iterative walks from #1768 and #1770 move in with their tests; the CLI warns on a blame error as before and the bindings stay silent, and the CLI now returns before opening a thread's blame session for a file with no descendants, as it did. Additive under STABILITY.md's `vcs` surface. The CLI's `--vcs-per-function` still implies `--vcs` and the bindings' `vcs_per_function` stays independent: the helper is two calls, so that remains each front-end's policy, as recorded. Verified by revert in the library: a skip in place of the `None` assignment fails the seeded tests, recursion in either walk aborts the 10 000-deep test, a breadth-first walk fails the pre-order fixture, and removing the no-descendants return fails its new test. Fixes #1743
`is_generated` matches `@generated`, `DO NOT EDIT` and `GENERATED CODE` anywhere in a file's first fifty lines, case-insensitively, and two hand-written files quoted those phrases in their leading comments: the module doc of `big-code-analysis-py/src/analysis.rs` named all three markers, and `big-code-analysis-cli/src/default_thresholds.rs` wrote "generated code" in a sentence. The self-scan skipped both as generated, so nothing in them had ever been measured by the threshold gate, and the gate reported only a count of skipped files. Both comments are reworded so no marker phrase appears in the window; `analyze_path`'s own doc still lists the markers, past line fifty. Measured for the first time, `analyze_path` reads `nexits` 6 against a limit of 5 and is baselined: three of its six exits are `?` propagations, and the three returns are the three distinct outcomes a caller must tell apart, so a split would move the number rather than clarify anything. A guard test walks the Rust and Python files the self-scan gates, runs `is_generated` over each, and requires every hit's first matching line to be a code generator's own marker line, so no allowlist tracks the generated set and a leading comment cannot hide a hand-written file again. It lives under `tests/`, outside the crates.io tarball, since it walks sibling crates the published crate does not carry, and it panics on a walk error so a renamed root cannot drop out of the census. Verified by revert: either original header fails it by name, as does a renamed root and a respelled Python marker. Fixes #1763
gix's `for_each_to_obtain_tree` builds a blob-diff platform per call for its rename tracker, whether or not rename tracking is on, and each build stats or loads the index, scans it for `.gitattributes` and probes the global attribute files; in a bare repository it rebuilds an index from `HEAD`'s tree every time. The history walk called it once per commit on top of the platform it already cloned for line counts, and the seed enumeration and `bca vcs commit`'s single diff each built one more. `WalkContext::open` now loads the index once and builds the template platform from it with the same calls `diff_resource_cache` makes, and keeps the index for the attribute digest #1760 adds. The walk clones the template twice per build — the visitor holds one for line counts, so the rename tracker needs its own — and clears both per commit, freeing the buffers as before (`_keep_allocation` was measured and rejected at +7–13 MB RSS for 1–2%). The seed enumeration and the JIT diff take a clone instead of a build. `open` now runs before the seed enumeration, which only changes which error wins on a corrupt `.git/shallow`. Output is unchanged; the cache-parity suites pin a hit against a fresh walk. A fixture pins the per-commit clears: gix keys the resource cache by blob id alone, so a blob reused at a `-diff`-bound path would serve its binary verdict to the next commit's rename check — dropping the rewrite clear loses the rename, dropping the line clear loses the file's churn, each verified by revert. Measured at e38740c4 with rustc 1.99.0 and gix 0.89.0 over this repository's 2 348 diffed commits, `bca vcs --no-cache --format json --paths .`, release build, `hyperfine --warmup 1 --runs 5`, against the same tree with only the `_with_cache` call reverted: index accesses 2 348 to 3 and global attribute probes 2 346 to 1 (`strace -f -c -e trace=statx,openat`); a bare clone 3.97 s ± 0.14 to 3.43 s ± 0.19; a non-bare one unchanged within noise (3.44 ± 0.06 to 3.52 ± 0.24); peak RSS under 1% apart (`/usr/bin/time -v`). Fixes #1761
The persistent history cache's fingerprint covered the diff configuration but not the `diff` attribute bindings that route a path to a driver, which gix resolves from the current index and attribute files for every historical commit. A binding change — a committed or staged `.gitattributes`, `$GIT_DIR/info/attributes`, the user file — rewrote the churn a fresh walk recorded while nothing in the key moved, and the incremental splice carried the stale tail under every new head until `--clear-cache`: the issue's fixture read 9 cached against 19 fresh through three splices. The fingerprint gains a term over the bindings' full content: the index's `.gitattributes` blobs by id, the bytes of the system file, the user file (`core.attributesFile`, else the XDG default) and `info/attributes`, and `core.ignoreCase`. Content, not resolved state: a per-path term over the index cold-walked on every file add or remove, and a set of winning rules missed a reorder of two overlapping rules and a case flip that bound a new path to a rule already winning elsewhere, both reproduced during review. `WalkContext::open` reads each file once and builds the platform's attribute stack from that same capture, so the walk resolves under exactly the bytes the entry is stamped with — the one-snapshot rule read and gix's own would otherwise stamp old churn with the new digest forever. Reproducing gix's stack from captured bytes needs its precedence kept: `info/attributes` outranks the root `.gitattributes` but not a nested one, so the root blob is withheld from the index mappings and appended to the globals just below the captured `info/attributes`; a parity test resolves `diff` through both constructions on a fixture where every pair of sources overlaps. The user file's location goes through `gix::path::env::var` for gix's `HOME` fallback, Windows' `PermissionDenied` on a directory reads as absent as it does in gix-glob, and the installation file is not read because no gix permission preset loads it. `CACHE_SCHEMA_VERSION` stays 2: the new term retires every earlier entry on its own; superseded entries stay on disk until `--clear-cache`. Verified by revert: dropping any term, or hashing the sources order-blind, fails its own test row, and the committed `.gitattributes` splice and a rule reorder are integration-tested against a fresh walk. Fixes #1760
One new entry and four sub-examples from the ten #1768 follow-ups. 113 names the mechanism #1760 took three designs to find: a cache keyed on a resolved function — path to attribute state — must fingerprint the resolver's sources, not a sample of its answers or the rules that won, since any summary of outputs drops the losers that decide other inputs. Sub-examples join 57 (#1764: a lexical index hit does not say which file supplied the bytes), 84 (#1771: a git version claim nobody checked decided whether a test could fail), 90 (#1760: the #1409 read-twice pairing recurred for the attribute files) and 97 (#1761: a walk timed against `main` credited nineteen commits to one).
dekobon
force-pushed
the
fix/batch-2026-11-01-2
branch
from
November 4, 2026 01:06
811c968 to
2fbb631
Compare
`installed()` joined `PATHEXT`'s entries onto the name as spelled — `.EXE`, upper case on every Windows runner — so the PATH candidate the hook probed and later ran was `bca.EXE`, a file that exists on no disk in that case. Windows resolves it anyway, which is why the hook kept working for a real `cargo install`; but the hook test's spawn routing matches the exact string it wrote, `bca.exe`, so on the Windows leg every PATH scenario spawned a Node script as a PE and the check came back with an empty stdout: three `Unexpected end of JSON input` failures in `bca-claude-hook-test.mjs`, on `main` since #1776 as well as on this branch. The extensions are lower-cased before the join. The case is the hook's to choose, and lower case names the file as cargo writes it and as `localBuilds` already spells it, so the health line reports the same spelling for a PATH match as for a local one.
This branch was previously deployed
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.
Ten follow-up issues filed from PR #1768's reviews, each landed as one signed commit on this branch. Every commit went through the same loop before it existed: implement with test-via-revert,
simplify-rust→rust-optimize→audit-tests, six parallel read-only reviewers (review,code-review --effort max, a performance audit, a least-reviewed-areas audit,astra-review, an architecture audit), remediation, and anastra-reviewpass over the fixes until clean; then the fullmake pre-commitgate. A whole-branch review ran at the end and its findings were folded into the commits they belong to.Commits
test: isolate git fixtures from host configgit inithelpers (the issue listed six) plus three Python fixtures takeGIT_CONFIG_GLOBAL,GIT_CONFIG_NOSYSTEMand aGIT_CONFIG_COUNT=2core.excludesFile/core.attributesFilepin — the two config variables alone leave$XDG_CONFIG_HOME/git/ignorelive. Hostile-config tests discriminate on every git through auser.namesentinel (init runs no hook before 2.46; the host has 2.34.1).feat(diff): roll up one-sided fields per family(file, bucket)row; JSON rows, summary counts and--exit-codeunchanged (byte-identical JSON for the issue's pair; Markdown 14 230 → 2 514 bytes).fix(cli): omit hotspot_score without cyclomaticselected.contains(Cyclomatic)with an explicitNone; bindings take the same assignment in place of a skip; parity test gains a restricted-selection row.fix(ast): error on a small-st_size directoryopen(2)succeeds on one; only the read fails), returning the platform's error; both downstream probes retired.perf(py): hash the blame-cache root once per filefix(cli): walk per-function injection iterativelyrefactor(vcs): own the hotspot complexity rulevcs::attach::{file_complexity, attach_file_history, attach_per_function_history}; the figure selector and gate are crate-private; all four sites (CLI--vcs,--vcs-per-function,report --vcs, bindings) route through it. Additive under STABILITY.md'svcssurface. The--vcs-per-functionimplies--vcsasymmetry is left as recorded — two independent calls keep it a front-end policy.fix(self-scan): stop hiding two files as generatedanalyze_path nexits 6baselined (3 of 6 exits are?); a census undertests/requires everyis_generatedhit to carry a generator's own marker line.perf(vcs): reuse one diff platform across the walk_keep_allocationwas measured and rejected). Index accesses 2 348 → 3, attribute probes 2 346 → 1.fix(vcs/cache): fingerprint attribute bindings.gitattributes(path, oid); bytes of the system, user andinfo/attributesfiles;core.ignoreCase), read once and feeding both the digest and the platform's attribute stack. Schema stays 2.docs(lessons): record the 2026-11-01 follow-upsDesign decisions the issues asked for
#1760 — neither candidate in the issue survived review. Per-path resolved state over the index (candidate 2) cold-walked on every file add/remove and missed paths deleted before
HEAD. A set of winning rules missed a reorder of two overlapping rules and acore.ignoreCaseflip — both reproduced — and hashing each winner's source path made-p .vs-p "$PWD"thrash the cache. Only the ordered content of every source gix loads is complete. The first content-based cut then read the files gix had just loaded for the stack — the #1409 read-twice pairing, reproduced with a FIFO — so the context now reads each source once intoAttributeSourcesand builds gix's stack from that capture, reproducing gix's precedence (info/attributesoutranks the root.gitattributesbut not a nested one) with a parity test against gix's own construction. The installation file is not read: every gix permission preset disables it. Remaining risk: a future gix adding a source kind this list omits fails toward staleness; a gix bump must re-checkassemble_attribute_globals.#1761 — measurement. Release build,
hyperfine --warmup 1 --runs 5,bca vcs --no-cache --format json --paths .on this repository (2 348 diffed commits), rustc 1.99.0, gix 0.89.0, against an isolated control (same tree with only the_with_cachecall reverted): index accesses 2 348 → 3 and global-attribute probes 2 346 → 1 (strace -f -c -e trace=statx,openat); bare clone 3.97 s ± 0.14 → 3.43 s ± 0.19; non-bare unchanged within noise (3.44 ± 0.06 → 3.52 ± 0.24) — the non-bare rebuild is onestatxfrom page cache. Peak RSS under 1 % apart. The issue's third bullet (clear_resource_cache_keep_allocation) was not adopted: measured during #1768's review at +7–13 MB RSS for 1–2 %.#1766 — JSON unchanged. The
{file, metric, field}row shape is still under[Unreleased], but the renderer-only collapse needs no change to it; a#[serde(skip)]flag carries the fact. The per-(metric, field)form with a file count is not implemented.#1743 — public surface.
attach_statsandHotspotComplexitywere narrowed topub(crate)in review: public, they would let a caller apply the wrong figure to a space — the bypass the module exists to prevent — and narrowing later is a 3.0 break.Verification
BCA_GATE: pass (gate=pre-commit)on the final tip (6 875 tests; pytest 406; stubtest clean);make check-test-lang-gates-compare COMPARE_REF=origin/mainclean; no.snap.new/.pending-snap; output submodule clean.make self-scanandmake self-scan-headroomon its own (git rebase --exec);.bca-baseline.tomlrefreshed per commit.Fixes #Neach.## Resolutionblock and a comment naming its commit by subject.Not in scope
The four pre-existing problems PR #1768's review named and did not file (
PyVcsOptionsdefault,--sincesymlink traversal, read-before-validate, unpruned cache entries) are untouched; #1760's commit notes that superseded cache entries remain on disk until--clear-cache.Fixes #1742, #1743, #1760, #1761, #1762, #1763, #1764, #1766, #1770, #1771